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
1、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
2、进入目录:/mcloud/creditshop_back/creditshopback/app/tmp/cache/persistent,查看所属用户与用户组,皆为:root。如图2
[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、参考网址:https://book.cakephp.org/2/zh/installation.html 。设置访问权限。app/tmp 目录及其子目录必须同时能够被 web 服务器和命令行用户写入。
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、编辑 Dockerfile。确保在 CakePHP 安装中 app/tmp 目录及其全部子目录可以被 web 服务器用户 写入。
chown -R 775 /mcloud/creditshop_back/creditshopback/app/tmp/ && \
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、升级后,Nginx 用户写入成功,访问正常。
近期评论