i have a Problem. My Website is only a White Clean Site. With no Error, like nothing there.
Running Ubuntu 16.04, NGINX and PHP5.6-fpm
/var/run/php/php5.6-fpm.sock is exists.
The Site is running before with my NGINX Settings, here is PHP location
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
try_files $uri =404;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
}
Before (Ubuntu 14.04 and PHP5-fpm) it was fastcgi_pass unix:/var/run/php/php5-fpm.sock;
But i cannot install php5-fpm anymore, cause Ubuntu 16.04 doesnt support it.
If i take a look to /var/log/nginx/error.log there is nothing! No Logs from the Site
I dont know what i can do... i tried php7.0 but also same look...
Outputs:
fpm grep
root 2214 0.0 0.1 14236 1024 pts/0 S+ 16:26 0:00 grep --color=auto fpm
root 31797 0.0 2.2 234016 22504 ? Ss 13:15 0:00 php-fpm: master process (/etc/php/5.6/fpm/php-fpm.conf)
www-data 31802 0.0 7.1 280008 72224 ? S 13:15 0:02 php-fpm: pool www
www-data 31803 0.0 5.9 280888 60328 ? S 13:15 0:01 php-fpm: pool www
nginx grep
root 319 0.0 0.2 125368 3040 ? Ss 13:32 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 320 0.0 0.6 125368 6776 ? S 13:32 0:00 nginx: worker process
root 2219 0.0 0.1 14236 1020 pts/0 S+ 16:27 0:00 grep --color=auto nginx
status nginx
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-09-21 13:32:45 CEST; 2h 55min ago
Process: 308 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCE
Process: 316 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 313 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 319 (nginx)
CGroup: /system.slice/nginx.service
├─319 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
└─320 nginx: worker process
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal nginx[313]: nginx: [warn] server name "/var/www/*****.de/htdocs" has suspiciou
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal nginx[313]: nginx: [warn] conflicting server name "*****.de" on 0.0.0.0:80, ignored
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal nginx[313]: nginx: [warn] conflicting server name "*****.de" on 0.0.0.0:80,
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal nginx[316]: nginx: [warn] server name "/var/www/*****.de/htdocs" has suspiciou
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal nginx[316]: nginx: [warn] conflicting server name "*****.de" on 0.0.0.0:80, ignored
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal nginx[316]: nginx: [warn] conflicting server name "*****.de" on 0.0.0.0:80,
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argum
Sep 21 13:32:45 Ubuntu-1404-trusty-64-minimal systemd[1]: Started A high performance web server and a reverse proxy server.
Related
I’ve managed to host a basic wordpress site on my raspberry pi (just a test site with barely anything on it) which is working correctly, but when trying to host a second wordpress site the exact same way as the first causes a duplicate upstream error:
rpi nginx[3001]: nginx: [emerg] duplicate upstream "wp-php-handler" in /etc/nginx/sites-enabled/test.wpsite.co.uk.conf:1
Maybe the wp-php-handler can only be used once. Does anyone know how to fix this so I can host multiple wordpress sites rather than just one? I’m also hosting other non-wordpress test sites on different domains that literally just have one page (I’m learning Nginx to host my own sites), although the conf files are configured differently to the wordpress sites and do not use wp-php-handler. From the tutorial I followed, I assume wp-php-handler may be required to run wordpress sites.
Here is the test.wpsite.co.uk.conf file in /etc/nginx/sites-available (also symlinked to sites-enabled):
upstream wp-php-handler {
server unix:/var/run/php/php7.4-fpm.sock;
}
server {
listen 1234;
server_name _;
root /var/www/test.wpsite.co.uk;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass wp-php-handler;
}
}
Note: it’s the same as the first (working) wordpress site but just with different port and root values. Whenever I remove the second wordpress site, the nginx server is able to restart and run successfully again, so I'm sure the second wordpress site is causing a problem.
Here’s what’s returned when running journalctl -xe:
lines 4736-4758/4758 (END)
-- Support: http://www.ubuntu.com/support
--
-- A reload job for unit nginx.service has begun execution.
--
-- The job identifier is 1463.
Sep 04 07:52:42 rpi nginx[3001]: nginx: [emerg] duplicate upstream "wp-php-handler" in /etc/nginx/sites-enabled/test.wpsite.co.uk.conf:1
Sep 04 07:52:42 rpi systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecReload= process belonging to unit nginx.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Sep 04 07:52:42 rpi systemd[1]: Reload failed for A high performance web server and a reverse proxy server.
-- Subject: A reload job for unit nginx.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A reload job for unit nginx.service has finished.
--
-- The job identifier is 1463 and the job result is failed.
Sep 04 07:52:42 rpi sudo[2998]: pam_unix(sudo:session): session closed for user root
And here’s what’s returned when running systemctl status nginx.service:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-09-03 17:39:57 UTC; 14h ago
Docs: man:nginx(8)
Process: 1673 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1782 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3009 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=1/FAILURE)
Main PID: 1783 (nginx)
Tasks: 5 (limit: 973)
CGroup: /system.slice/nginx.service
├─1783 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─1784 nginx: worker process
├─1785 nginx: worker process
├─1786 nginx: worker process
└─1787 nginx: worker process
Sep 03 17:39:54 rpi systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 03 17:39:57 rpi systemd[1]: Started A high performance web server and a reverse proxy server.
Sep 04 07:52:42 rpi systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 04 07:52:42 rpi nginx[3001]: nginx: [emerg] duplicate upstream "wp-php-handler" in /etc/nginx/sites-enabled/test.wpsite.co.uk.conf:1
Sep 04 07:52:42 rpi systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Sep 04 07:52:42 rpi systemd[1]: Reload failed for A high performance web server and a reverse proxy server.
Sep 04 07:54:57 rpi systemd[1]: Reloading A high performance web server and a reverse proxy server.
Sep 04 07:54:57 rpi nginx[3009]: nginx: [emerg] duplicate upstream "wp-php-handler" in /etc/nginx/sites-enabled/test.wpsite.co.uk.conf:1
Sep 04 07:54:57 rpi systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Sep 04 07:54:57 rpi systemd[1]: Reload failed for A high performance web server and a reverse proxy server.
Thanks for any help here
Turns out that changing wp-php-handler to wp-php-handler-two for the new wordpress site's conf file made it work
Nginx returns in browser the page
403 Forbidden
Is it my data:
/etc/nginx/sites-enabled/lar.template
upstream phpapp {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name www.lar.app lar.app;
root /home/vagrant/lar/public;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass phpapp;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_log /var/log/nginx/lar_error.log;
access_log /var/log/nginx/lar_access.log;
}
/etc/nginx/nginx.conf
user vagrant;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.*;
}
/etc/opt/remi/php71/php-fpm.d/www.conf
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = vagrant
; RPM: Keep a group allowed to write in log dir.
group = vagrant
listen = 127.0.0.1:9000
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = vagrant
listen.group = vagrant
$ ls -l /home/vagrant/lar
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 app
-rwxrwxr-x. 1 vagrant vagrant 1646 дек 3 09:03 artisan
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 bootstrap
-rw-rw-r--. 1 vagrant vagrant 1283 дек 3 09:03 composer.json
-rw-rw-r--. 1 vagrant vagrant 124490 дек 3 09:15 composer.lock
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 config
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 database
-rw-rw-r--. 1 vagrant vagrant 558 дек 3 09:03 gulpfile.js
-rw-rw-r--. 1 vagrant vagrant 401 дек 3 09:03 package.json
-rw-rw-r--. 1 vagrant vagrant 930 дек 3 09:03 phpunit.xml
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 public
-rw-rw-r--. 1 vagrant vagrant 1918 дек 3 09:03 readme.md
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 resources
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 routes
-rw-rw-r--. 1 vagrant vagrant 563 дек 3 09:03 server.php
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 storage
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:03 tests
drwxrwxr-x. 1 vagrant vagrant 4096 дек 3 09:15 vendor
ps -aux | grep php
root 1080 0.0 1.9 578248 37264 ? Ss 09:40 0:01 php-fpm: master process (/etc/opt/remi/php71/php-fpm.conf)
vagrant 2334 0.0 0.5 578248 9752 ? S 09:40 0:00 php-fpm: pool www
vagrant 2335 0.0 0.5 578248 9752 ? S 09:40 0:00 php-fpm: pool www
vagrant 2336 0.0 0.5 578248 9752 ? S 09:40 0:00 php-fpm: pool www
vagrant 2337 0.0 0.5 578248 9752 ? S 09:40 0:00 php-fpm: pool www
vagrant 2338 0.0 0.5 578248 9756 ? S 09:40 0:00 php-fpm: pool www
vagrant 6838 0.0 0.0 112672 972 pts/0 D+ 11:53 0:00 grep --color=auto php
ps -aux | grep nginx
root 1617 0.0 0.0 47792 1232 ? Ss 09:40 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
vagrant 1618 0.0 0.1 48328 2240 ? S 09:40 0:00 nginx: worker process
vagrant 6840 0.0 0.0 112672 976 pts/0 R+ 11:55 0:00 grep --color=auto nginx
lar_error.log
2016/12/03 09:40:54 [error] 1618#1618: *1
"/home/vagrant/lar/public/index.php" is forbidden (13: Permission
denied), client: 192.168.5.1, server: www.lar.app, request: "GET /
HTTP/1.1", host: "lar.app" 2016/12/03 09:40:54 [error] 1618#1618: *1
open() "/home/vagrant/lar/public/favicon.ico" failed (13: Permission
denied), client: 192.168.5.1, server: www.lar.app, request: "GET
/favicon.ico HTTP/1.1", host: "lar.app" 2016/12/03 09:40:54 [error]
1618#1618: *1 open() "/home/vagrant/lar/public/favicon.ico" failed
(13: Permission denied), client: 192.168.5.1, server:
$ groups vagrant
vagrant: vagrant nginx apache
What is the cause here? Thanks in advance
i can't make work nginx with php-fpm. Googled whole day, tried everything but no result.
Any request is 502 and in error log i see this:
# tail /var/log/**/*error*.log
==> /var/log/nginx/acme.www.error.log <==
2016/08/16 04:24:14 [crit] 930#930: *1 connect() to unix:/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 10.0.2.2, server: acme.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock:", host: "www.acme.dev:8080"
More tech info about my configuration here (it's almost default from repos):
# uname -a
Linux vagrant-ubuntu-trusty-64 3.13.0-93-generic #140-Ubuntu SMP Mon Jul 18 21:21:05 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
# php -v
PHP 5.6.24 (cli) (built: Aug 16 2016 02:28:22)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
# phpbrew fpm which
/root/.phpbrew/php/php-5.6.24/sbin/php-fpm
# /root/.phpbrew/php/php-5.6.24/sbin/php-fpm -v
PHP 5.6.24 (fpm-fcgi) (built: Aug 16 2016 02:28:29)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
# /root/.phpbrew/php/php-5.6.24/sbin/php-fpm -t
[16-Aug-2016 04:09:42] NOTICE: configuration file /root/.phpbrew/php/php-5.6.24/etc/php-fpm.conf test is successful
# cat /root/.phpbrew/php/php-5.6.24/etc/php-fpm.conf | egrep 'user|owner|group|mode'
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
# nginx -v
nginx version: nginx/1.10.1
# cat /etc/nginx/nginx.conf | egrep 'user|owner|group|mode'
user www-data;
# cat /etc/nginx/snippets/fastcgi-php.conf | grep fastcgi_pass
fastcgi_pass unix:/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock;
# fastcgi_pass unix:/root/.phpbrew/php/php-7.0.9/var/run/php-fpm.sock;
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# date +%Y-%m-%d\ %H:%M:%S
2016-08-16 04:21:21
# ls -ahlFG /root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock
srw-rw---- 1 www-data 0 Aug 16 04:02 /root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock=
# getfacl /root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock
getfacl: Removing leading '/' from absolute path names
# file: root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock
# owner: www-data
# group: www-data
user::rw-
group::rw-
other::---
# groups nginx
nginx : nginx www-data
# groups www-data
www-data : www-data nginx
# ps aux | grep -F -e php -e nginx
root 2660 0.0 0.1 91500 1596 ? Ss 03:57 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 2661 0.1 0.3 92200 3612 ? SN 03:57 0:02 nginx: worker process
www-data 2662 0.0 0.3 92200 3120 ? SN 03:57 0:00 nginx: worker process
www-data 2664 0.1 0.3 92200 3612 ? SN 03:57 0:02 nginx: worker process
root 2712 0.0 1.0 251288 10276 ? Ss 04:02 0:00 php-fpm: master process (/root/.phpbrew/php/php-5.6.24/etc/php-fpm.conf)
www-data 2713 0.0 0.9 251288 9216 ? S 04:02 0:00 php-fpm: pool www
www-data 2714 0.0 0.9 251288 9216 ? S 04:02 0:00 php-fpm: pool www
root 3101 0.0 0.0 11920 788 pts/0 R+ 04:20 0:00 grep --color=auto -F -e php -e nginx
I'm lost with this and even don't know how to search where is error.
With php-7.0.9 – same error.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I got a brand new Centos 7 server and would like to install laravel + nginx
I added Remi repo for PHP5.6
Also added epel
yum update
yum install nmap rsync nano wget curl
yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
nano /etc/yum.repos.d/remi.repo
yum install nginx
systemctl start nginx
systemctl enable nginx
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
#PHP
yum install php php-mysql php-fpm php-dom php-mcrypt php-mbstring
nano /etc/php.ini
cgi.fix_pathinfo=0
nano /etc/php-php.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nobody
listen.group = nobody
user = nginx
group = nginx
systemctl start php-fpm
systemctl enable php-fpm
The NGINX server is working, and phpinfo(); is looking good too.
inside /etc/nginx/nginx.conf:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
#root /usr/share/nginx/html;
root /usr/share/nginx/html/lv/public;
index index.php index.html index.htm
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
Inside /usr/share/nginx/html/lv I have installed alaravel 5 project via git.
[root#213 lv]# ls -la
total 164
drwxr-xr-x. 11 nginx nginx 4096 Jan 28 02:19 .
drwxr-xr-x. 3 root root 4096 Jan 28 02:17 ..
drwxrwxr-x. 15 nginx nginx 4096 Oct 21 10:44 app
-rw-rw-r--. 1 nginx nginx 1635 Aug 19 08:57 artisan
drwxrwxr-x. 2 nginx nginx 39 Nov 28 01:22 bootstrap
-rw-rw-r--. 1 nginx nginx 1007 Aug 19 08:57 composer.json
-rw-rw-r--. 1 nginx nginx 107281 Aug 19 08:57 composer.lock
drwxrwxr-x. 2 nginx nginx 4096 Aug 19 08:57 config
drwxrwxr-x. 4 nginx nginx 52 Aug 19 08:57 database
-rw-rw-r--. 1 nginx nginx 503 Aug 19 08:57 gulpfile.js
-rw-rw-r--. 1 nginx nginx 79 Aug 19 08:57 package.json
-rw-rw-r--. 1 nginx nginx 87 Aug 19 08:57 phpspec.yml
-rw-rw-r--. 1 nginx nginx 729 Aug 19 08:57 phpunit.xml
drwxrwxr-x. 4 nginx nginx 4096 Nov 28 01:03 public
-rw-rw-r--. 1 nginx nginx 1724 Aug 19 08:57 readme.md
drwxrwxr-x. 5 nginx nginx 42 Aug 19 08:57 resources
-rw-rw-r--. 1 nginx nginx 561 Aug 19 08:57 server.php
drwxrwxrwx. 6 nginx nginx 76 Aug 19 08:57 storage
drwxrwxr-x. 2 nginx nginx 47 Aug 19 08:57 tests
drwxrwxr-x. 29 nginx nginx 4096 Aug 19 08:57 vendor
[root#213 lv]# cd storage
[root#213 storage]# ls -la
total 12
drwxrwxr-x. 6 nginx nginx 76 Aug 19 08:57 .
drwxr-xr-x. 11 nginx nginx 4096 Jan 28 02:19 ..
drwxrwxr-x. 2 nginx nginx 23 Aug 19 08:57 app
drwxrwxr-x. 3 nginx nginx 21 Aug 19 08:57 documents
drwxrwxr-x. 5 nginx nginx 62 Aug 19 08:57 framework
-rwxrwxr-x. 1 nginx nginx 11 Aug 19 08:57 .gitignore
drwxrwxrwx. 2 nginx nginx 4096 Jan 27 14:01 logs
logs is empty.
I still get the following the error:
PHP message: PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/usr/share/nginx/html/lv/storage/logs/laravel-2016-01-28.log" could not be opened: failed to open stream: Permission denied' in /usr/share/nginx/html/lv/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:95
Stack trace:
#0 /usr/share/nginx/html/lv/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\Handler\StreamHandler->write(Array)
#1 /usr/share/nginx/html/lv/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)
#2 /usr/share/nginx/html/lv/vendor/monolog/monolog/src/Monolog/Logger.php(269): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#3 /usr/share/nginx/html/lv/vendor/monolog/monolog/src/Monolog/Logger.php(545): Monolog\Logger->addRecord(400, 'exception 'Symf...', Array)
#4 /usr/share/nginx/html/lv/vendor/larav
So I ran whoami.php which has `echo shell_exec('whoami');' in it, and the user is nginx.
So I don't get the problem
I found the problem
SELinux was turned on:
nano /etc/sysconfig/selinux
set to disabled
I am having some permission issues with Nginx and Php fastcgi when trying to get to the php file. I am using 5.5.15 and Nginx 1.6.0 in Redhat 7 .
My php file is very simple for now.
<?php
echo "\nscript owner : ".get_current_user()."\n";
$myFile = '/usr/share/nginx/html/test.log';
$fh = fopen($myFile, 'a') or die("can''t open file");
?>
Get current user will result in : "myuser"
The error that I am getting is the following:
2014/08/26 22:47:14 [error] 6424#0: *16 FastCGI sent in stderr: "PHP message: PHP Warning: fopen(/usr/share/nginx/html/test.log): failed to open stream: Permission denied in /usr/share/nginx/html/test.php on line 19" while reading response header from upstream, client: XXXXXX, server: XXXXXXX, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "XXXXXXX"
Here is the permissions for the directory /usr/share/nginx( all of the parent directories have x permissions):
drwxrwsrwx. 4 myuser myuser 4096 Aug 26 22:32 html
Running the following commands:
$ ps aux | grep "nginx: worker process"
myuser 6423 0.0 0.3 111228 3880 ? S 22:36 0:00 nginx: worker process
myuser 6424 0.0 0.5 111228 5428 ? S 22:36 0:00 nginx: worker process
myuser 6480 0.0 0.0 112640 980 pts/0 R+ 22:41 0:00 grep --color=auto nginx: worker process
$ ps aux | grep "php"
myuser 5930 0.0 0.1 128616 1860 pts/0 T 21:09 0:00 vi /etc/php-fpm.conf
myuser 5931 0.0 0.2 128628 2052 pts/0 T 21:09 0:00 vi /etc/php.ini
myuser 5933 0.0 0.1 128616 1864 pts/0 T 21:13 0:00 vi /etc/php-fpm.conf
myuser 5934 0.0 0.1 128616 1860 pts/0 T 21:14 0:00 vi /etc/php-fpm.d/www.conf
myuser 5935 0.0 0.1 128616 1864 pts/0 T 21:15 0:00 vi /etc/php-fpm.conf
root 6313 0.0 2.4 544732 25208 ? Ss 22:25 0:00 php-fpm: master process (/etc/php-fpm.conf)
myuser 6314 0.0 0.8 544732 8356 ? S 22:25 0:00 php-fpm: pool www
myuser 6315 0.0 0.8 544732 8328 ? S 22:25 0:00 php-fpm: pool www
myuser 6316 0.0 0.9 545076 9892 ? S 22:25 0:00 php-fpm: pool www
myuser 6317 0.0 0.9 544860 9452 ? S 22:25 0:00 php-fpm: pool www
myuser 6318 0.0 0.9 544860 9212 ? S 22:25 0:00 php-fpm: pool www
myuser 6483 0.0 0.0 112640 976 pts/0 R+ 22:47 0:00 grep --color=auto php
My Server looks like the following:
server {
listen 80;
root /usr/share/nginx/html;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
And in the nginx.config I am using the same user: "user ec2-user;"
I have also changed the /etc/php-fpm.d/www.conf file to have the same user and group.
user = myuser
group = myuser
So, both Nginx and PHP are running on the same user "myuser".
All the directories up to where the log file and the php file are located(/usr/share/nginx/html) have x access and that user has 777 access to that html directory.
Not sure what I am missing. I have been searching online for 2 days now but no luck.
I suppose rights are correct, but you have 3 line of code in test.php, but due to error this is not true :) Check what file you run.
"in /usr/share/nginx/html/test.php on line 19"