没有不值得去解决的问题,也没有不值得去学习的技术!

Deploying CakePHP 2.x: Warning: SplFileInfo::openFile(/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /lib/Cake/Cache/Engine/FileEngine.php on line 356

Deploying CakePHP 2.x, Warning: SplFileInfo::openFile(/mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /mcloud/creditshop_back/creditshopback/lib/Cake/Cache/Engine/FileEngine.php on line 356.

1. Deploying CakePHP 2.x, Warning: SplFileInfo::openFile(/mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /mcloud/creditshop_back/creditshopback/lib/Cake/Cache/Engine/FileEngine.php on line 356. As shown in Figure 1

Deploying CakePHP 2.x, Warning: SplFileInfo::openFile(/mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /mcloud/creditshop_back/creditshopback/lib/Cake/Cache/Engine/FileEngine.php on line 356.
Figure 1

2. Enter the directory: /mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent, and check the owning user and user group; both are: root. As shown in Figure 2

Enter the directory: /mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent, and check the owning user and user group; both are: root.
Figure 2
Plaintext

[root@back-86667bcfcb-p95js /]# cd /mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent
[root@back-86667bcfcb-p95js persistent]# ls -l
total 20
-rw-rw-r-- 1 root  root    43 Apr  7 20:15 myapp_cake_core_cake_console_zho
-rw-rw-r-- 1 root  root    43 Apr  7 20:15 myapp_cake_core_cake_dev_zho
-rw-rw-r-- 1 nginx nginx  225 Apr  8 10:06 myapp_cake_core_default_zho
-rw-rw-r-- 1 root  root  3239 Apr  7 20:15 myapp_cake_core_file_map
-rw-rw-r-- 1 nginx nginx  633 Apr  8 10:06 myapp_cake_core_method_cache
[root@back-86667bcfcb-p95js persistent]# 

3. Reference URL: https://book.cakephp.org/2/zh/installation.html . Set access permissions. The app/tmp directory and its subdirectories must be writable by both the web server and command-line users.

Plaintext

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
setfacl -R -m u:${HTTPDUSER}:rwx app/tmp
setfacl -R -d -m u:${HTTPDUSER}:rwx app/tmp

4. Edit the Dockerfile. Ensure that the app/tmp directory and all its subdirectories are writable by the web server user in the CakePHP installation.

Dockerfile

    chown -R 775 /mcloud/creditshop_back/creditshopback/app/tmp/ && \

Dockerfile

    cd /mcloud/creditshop_back/creditshopback &&\
    HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1` &&\
    setfacl -R -m u:${HTTPDUSER}:rwx app/tmp &&\
    setfacl -R -d -m u:${HTTPDUSER}:rwx app/tmp &&\

5. After the upgrade, the Nginx user successfully writes files, and access is normal.

 

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系