nginx: [alert] could not open error log file
Description
The template seems to have fundamental errors. When I use the exact same language and try to recreate the nginx and php containers only since I do not need a postgre nor a redis container, I always get the same nginx: [alert] that cannot open the error log in the wrong path. It should save it to "/var/logs/*". As a result my php container does not run and exits at (1) whenever I run docker compose.
Steps to reproduce
- Using the same example dockerfile example (without postgre & redis, only nginx and and php)
- replacing the volume paths to mount
Additional info
- Craft version:
- PHP version:
- Database driver & version:
- Plugins & versions:
Hey @Frantz-Renard in line 32 you mount ./php/craft/html/index.php:/php/craft/htm/lindex.php is htm/lindex.php right?
I'm not confident this will get resolved since the repo itself is deprecated, but the issue mentioned here is tied to this commit: https://github.com/craftcms/docker/commit/5a1018c2a4681c0b67adbd7c0c17edd7b71914ce
The issue itself is in the fact that the author of the commit CHOWN-ed a symlink and not the actual folder, which is: /var/log/nginx
Adding this to your Dockerfile should resolve the issue if somebody still has it:
RUN chown -R www-data:www-data /var/log/nginx
Alternative is:
chown -RL www-data:www-data /var/lib/nginx/
The -L flag enables following on symbolic links, which should also do the trick.
If you can confirm this, I will gladly do a PR on the image that still seems to be used. However, I would suggest checking out the new https://github.com/craftcms/image repository, which supports PHP 8.3 and 8.4.