Need configuration for tmp folder and logs in cakephp 4.5

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.cake.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.default.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.default.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.cake.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: file_put_contents(/var/www/html/logs/error.log): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 142

I have recently upgraded the cakephp application from 3.4 to 4.5 and the whole application is working normally but when i am running the application in debug mode i am having the above errors for permissions. PLEASE help me withe permission configurations for tmp folder and logs.

cd /var/www/html/tmp
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 755 /var/www/html/tmp

it could also be, that you need group permissions as well, so

cd /var/www/html/tmp
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
chmod 775 /var/www/html/tmp

just depends on how/with what user your PHP is executed

Also jumping directly from 3.4 to 4.5 is quite the major jump. But good luck solving all the errors :grin:

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.cake.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.default.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.default.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: SplFileInfo::openFile(/var/www/html/tmp/cache/persistent/myapp_cake_core_translations.cake.en_US): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php on line 393

Warning: file_put_contents(/var/www/html/logs/error.log): Failed to open stream: Permission denied in /var/www/html/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 142

Warning: Unable to emit headers. Headers sent in file=/var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php line=393 in /var/www/html/vendor/cakephp/cakephp/src/Http/ResponseEmitter.php on line 71

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:393) in /var/www/html/vendor/cakephp/cakephp/src/Http/ResponseEmitter.php on line 168

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/vendor/cakephp/cakephp/src/Cache/Engine/FileEngine.php:393) in /var/www/html/vendor/cakephp/cakephp/src/Http/ResponseEmitter.php on line 197

Still i am getting the same errors after running those permission set commands… Please help

So you are running a docker. I am not a docker expert but it seems the webserver is executing php with a different user than what your tmp folder is allowed to be written to.

You can create a nfo.php in your webroot directory with this content

<?php
phpinfo();

and check the user which is being used to execute PHP. It all depends on what PHP Setup you are using, could be FPM, could be CGI.

With the current information I just can’t tell you “do X and its fixed” since there are so many ways how one can configure a docker setup. You need to tell me more on what your setup is currently doing.

Currently, I have a docker file where we are installing all the required packeges to start the applications and we are running few permission set commands in the docker file. The permission set commands currently i am using is

`EXPOSE 8002
COPY . /var/www/html/

RUN usermod -u 1000 www-data

RUN chown -R www-data:www-data /var/www/html

Permission to non root users

RUN chmod 777 -R /var/www/html/logs/ /var/www/html/tmp/ /var/www/html/vendor/ /var/www/html/webroot/uploads/

USER www

COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
RUN chmod -R 777 /etc/apache2 && chgrp -R 0 /etc/apache2
CMD sed -i “s/80/8002/g” /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground

RUN a2enmod rewrite`

so after running those chmod permission set commands i am turning up the apache server to run the application.

NOTE: If am not running the application in debug mode, The application is perfectly working fine. but when it is running on debug, I am having the above mentioned warnings.

You can find the application structure in below screenshot:

This is the docker file image after adding the earlier mentioned commands to it: