rick645 Posted November 26, 2022 Share Posted November 26, 2022 (edited) $ cat master/.htaccess RewriteEngine On RewriteRule ^(.*)$ src/index-debug.php [L] $ cat docker-compose.yml services: web: build: . ports: - 8014:80 volumes: - .:/var/www/html - ./docker/volumes/etc/php.ini:/usr/local/etc/php/php.ini $ cat Dockerfile FROM php:apache RUN a2enmod rewrite $ cat master/src/index-debug.php <?php error_log("error message 123"); var_dump( ini_get('error_log'), ini_get('log_errors'), file_get_contents('/var/log/error.log'), ); $ cat docker/volumes/etc/php.ini log_errors = On error_log = /var/log/error.log $ docker-compose up -d WARNING: Found orphan containers (xxx) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. Starting xxx... done $ curl http://localhost:8014/master/src/index-debug.php string(18) "/var/log/error.log" string(1) "1" <b>Warning</b>: file_get_contents(/var/log/error.log): Failed to open stream: No such file or directory in <b>/var/www/html/master/src/index-debug.php</b> on line <b>4</b><br /> bool(false) Why? Edited November 26, 2022 by rick645 Quote Link to comment https://forums.phpfreaks.com/topic/315583-docker-error_log-not-work/ Share on other sites More sharing options...
Solution gizmola Posted November 26, 2022 Solution Share Posted November 26, 2022 The PHP process may not be able to write to the /var/log directory. Assuming it's the apache user that php is running as in this case. Connect to the container and check out the perms for /var/log. Quote Link to comment https://forums.phpfreaks.com/topic/315583-docker-error_log-not-work/#findComment-1602966 Share on other sites More sharing options...
requinix Posted November 27, 2022 Share Posted November 27, 2022 Why did you change the error log path at all? The php:apache image should have set everything up for you already. Quote Link to comment https://forums.phpfreaks.com/topic/315583-docker-error_log-not-work/#findComment-1602974 Share on other sites More sharing options...
rick645 Posted December 4, 2022 Author Share Posted December 4, 2022 On 11/26/2022 at 10:06 PM, gizmola said: The PHP process may not be able to write to the /var/log directory. Assuming it's the apache user that php is running as in this case. Connect to the container and check out the perms for /var/log. $ chown www-data:www-data /var/log/error.log Solved!!! Quote Link to comment https://forums.phpfreaks.com/topic/315583-docker-error_log-not-work/#findComment-1603250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.