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

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

[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.
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.
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. After the upgrade, the Nginx user successfully writes files, and access is normal.
