My PHP script has an error. For example, this shows this on the screen:
Warning: require(/var/www/foo.php): failed to open stream:
Where can I find this in the logs?
I tried docker logs containerName, but it only shows access logs. E.g.,
192.168.2.1 - - [17/Mar/2019:10:00:00 +0000] "GET / HTTP/1.1" 200 505 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64)...
It doesn't show the PHP error above.
Going in the Apache logs folder inside the container via docker exec shows the following:
ls -hltra /var/log/apache2
total 0
lrwxrwxrwx. 1 www-data www-data 11 Feb 6 04:42 other_vhosts_access.log -> /dev/stdout
lrwxrwxrwx. 1 www-data www-data 11 Feb 6 04:42 error.log -> /dev/stderr
lrwxrwxrwx. 1 www-data www-data 11 Feb 6 04:42 access.log -> /dev/stdout
I'm not even sure if this is where the PHP logs are at, but I can't view them.
Where can I find the Apache/PHP error logs in Docker?
Ensure that you have the following inside php.ini in order to be able to see the errors using docker logs -f containerName as in general, sending the logs to /dev/stdout and /dev/stderr makes you able to receive it through docker logs:
log_errors = On
error_log = /dev/stderr
To only see PHP logs, try:
docker logs -f [containerName] >/dev/null
To see all logs, try:
docker logs -f [containerName]
Related
I have installed CentOS 7 with Apache Web Server and PHP. But when I try to test php I've got this error
The user and group of info.php are "apache"
My Document Root is defined like you can see:
If I try to access with http://localhost it works, but when I try to access with http://localhost/info.php then it fails!!!
I have installed php and php-fpm package. Maybe Would I need other packages?
What am I doing wrong?
Edit I:
Looking for an error in access_log file I have found this error:
Why I get this error?
Edit II:
Looking for in error_log file I have found that is a problem of permissions:
[Tue Jul 24 18:44:21.084670 2018] [mime_magic:error] [pid 4986] [client ::1:38162] AH01512: mod_mime_magic: can't read `/var/www/html/info.php'
[Tue Jul 24 18:44:21.084848 2018] [core:error] [pid 4986] (13)Permission denied: [client ::1:38162] AH00132: file permissions deny server access: /var/www/html/info.php
But the file belongs to "apache" user and group ... :(
Edit III:
The solution to the problem is:
sudo chcon -R -v -t httpd_sys_rw_content_t info.php
How #Lou said it was a SELinux problem.
I was reluctant to disable SELINUX completely. This is what worked for me: restorecon -R /var/www/html/
I get 500 status on some of the php pages for Sentrifugo and to find out what
's going wrong I tried setting up error logging
The configuration can be found in this gist
However, on the pages that I get a 500, I do not see any log entries in any of these files
/var/log/php7.0-fpm.log
/var/log/php_errors.log
The worker pool log diectory is empty
anadi#foo:~$ sudo ls -ltr /var/log/php-fpm/
total 0
All I see is a 500 status logged in the access.log with no imformation at all that could help me troubleshoot
XX.XXX.XX.XX - - [13/Mar/2017:13:48:53 +0530] "GET /index.php/wizard/configuresite HTTP/2.0" 500 390 "https://foo.bar.com/index.php/wizard/managemenu" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
There's no entries in /var/log/nginx/foo/error.log neither
Update
All log directories are writable by the respective owner
anadi#foo:~$ ps -ef | grep php
root 19453 1 0 15:24 ? 00:00:00 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
www-data 19458 19453 0 15:24 ? 00:00:00 php-fpm: pool www
www-data 19459 19453 0 15:24 ? 00:00:00 php-fpm: pool www
anadi#foo:~$ ls -ltr /var/log/ | grep php
-rw-r--r-- 1 root root 1679 Mar 13 10:47 php_errors.log
drwxr-xr-x 2 www-data www-data 4096 Mar 13 15:23 php-fpm
-rw------- 1 root root 13590 Mar 13 15:24 php7.0-fpm.log
anadi#foo:~$ ls -ltr /var/log/php-fpm/
total 4
-rw-r--r-- 1 www-data www-data 0 Mar 13 15:23 www.error.log
-rw-r--r-- 1 www-data www-data 2041 Mar 13 15:34 www.access.log
anadi#foo:~$ ps -ef | grep nginx
root 19632 1 0 15:27 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 19633 19632 0 15:27 ? 00:00:00 nginx: worker process
www-data 19634 19632 0 15:27 ? 00:00:00 nginx: worker process
anadi#foo:~$ ls -ltr /var/www/
total 8
drwxrwxr-x 2 www-data www-data 4096 Mar 3 21:18 html
drwxr-xr-x 10 www-data www-data 4096 Mar 13 15:31 foo
anadi#foo:~$ ls -ltr /var/log/nginx/
total 16
drwxr-xr-x 2 www-data www-data 4096 Mar 13 09:58 foo
-rw-r--r-- 1 root root 1105 Mar 13 15:08 error.log
-rw-r--r-- 1 root root 5384 Mar 13 15:41 access.log
Did changes to display_errors setting as explained in one of the answers, but this still does not give any helpful log output for troubleshooting.
Here's extract of var/log/php-fpm/www.acccess.log
- - 13/Mar/2017:15:32:11 +0530 "GET /index.php" 500 /var/www/tribe/index.php 34.722 2048 57.60%
- - 13/Mar/2017:15:34:14 +0530 "GET /index.php" 500 /var/www/tribe/index.php 20.952 4096 95.46%
search for log file in your project
And In your php.ini you can find display_errors = Off make it equal On
I am not sure why, but downgrading to PHP 5 solved all of it, error logs populate as expected, and the intermittent 500 status codes have disappeared
I am getting the following error in my Nginx error.log file, what do I need to do to prevent this from happening?
2016/06/28 09:43:37 [crit] 1631#0: *1 connect() to
unix:/run/php/php5.6 fpm.sock failed (13: Permission denied) while
connecting to upstream, client: 192.168.56.1, server: my-vm, request:
"GET / HTTP/1.1", upstream:
"fastcgi://unix:/run/php/php5.6-fpm.sock:", $host: "my-vm-1"
Nginx runs with www-data permissions. The permissions of the folder that the error message is referencing (/run/php/php5.6-fpm.sock) are as follows:
drwxr-xr-x 20 root root 700 Jun 28 09:45 run
drwxr-xr-x 2 www-data www-data 80 Jun 28 09:44 php
srw-rw---- 1 www-data www-data 0 Jun 28 09:44 php5.6-fpm.sock
The user/group of PHP (/etc/php/5.6/fpm/pool.d/www.conf) is:
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
The nginx.conf file does not have any user value set. Some people have suggested setting this to www-data, but if I set this the Nginx service won't start, hence why it is ommitted.
I fixed this by adding the following user directive to the top of my nginx.conf file:
user www-data www-data;
I'm working with the official PHP docker image and I'm trying to add a host path as a VOLUME. My intent is for local development.
My Dockerfile is pretty basic:
FROM php:5.6-apache
VOLUME ["/var/www/html/"]
Then in my docker run command I'm just adding the -v flag:
$ docker run -d -v ~/Workspace/website/:/var/www/html/ ...
However, I get a 403 after start. If I execute a bash entry I can see /var/www/html is permission denied. I think this has to do with the "alien" user/group for the guest.
Log:
[Tue Jan 26 00:29:38.182727 2016] [core:error] [pid 10] (13)Permission denied: [client 192.168.5.1:37996] AH00035: access to /index.php denied (filesystem path '/var/www/html/index.php') because search permissions are missing on a component of the path
192.168.5.1 - - [26/Jan/2016:00:29:38 +0000] "GET /index.php HTTP/1.1" 403 446 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
Stat:
# stat html/
File: 'html/'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd02h/64770d Inode: 3148160 Links: 26
Access: (0775/drwxrwxr-x) Uid: ( 1000/ UNKNOWN) Gid: ( 1000/ UNKNOWN)
Access: 2016-01-25 23:17:57.096095138 +0000
Modify: 2016-01-26 00:28:10.274181924 +0000
Change: 2016-01-26 00:28:10.274181924 +0000
UPDATE
I took Geany's suggestion and change the gid of the www-data group to 1000 to match the gid of the host's path.
$ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ groupmod -g 1000 www-data
$ id www-data
uid=33(www-data) gid=1000(www-data) groups=33(www-data)
$ stat html/
File: 'html/'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd02h/64770d Inode: 3148160 Links: 26
Access: (0775/drwxrwxr-x) Uid: ( 1000/ UNKNOWN) Gid: ( 1000/ www-data)
Access: 2016-01-25 23:17:57.096095138 +0000
Modify: 2016-01-26 00:28:10.274181924 +0000
Change: 2016-01-26 00:28:10.274181924 +0000
However, this still did not fix the permissions. I even changed the uid.
UPDATE #2
I just confirmed this works flawlessly on OS X. I was originally trying to make it work on Fedora 23.
You should check user and group of apache worker processes and chown source directory.
Another way is change gid and uid of apache worker user.
I am using Ubuntu 14.04 and I am trying to install Laravel framework. In this purpose I have run this code in terminal:
php artisan serve
After waiting for 4-5 minutes I got this response:
Laravel development server started on http://localhost:8000/
[Tue May 26 13:19:40 2015] 127.0.0.1:44800 [200]: /favicon.ico
[Tue May 26 13:19:40 2015] 127.0.0.1:44801 [200]: /favicon.ico
After waiting for more than 10 minutes I got no more response although terminal is working.
Does it really take that much time? Or what's wrong?
then, what can I do? although port 8000 has been started,
localhost:8000 shows that, Sorry, the page you are looking for could
not be found.
You need to stop the server and run this command which specifies the public directory php -S localhost:8000 -t public/ as the root document root
or
you can also cd into your laravelProject/public then php -S localhost:8000