Conclusion : Ok so, now my configuration works, and I think the problem comes from the location of my project, in another user's directory. For some reasons, the either nginx or php-fpm is unhappy with it, and doesn't seem to work.
What's still bugging me is that it was a 404 error, not a 403.
Well, I don't think I will find the final answer.
I have read zillions of ways to do that, and unfortunately I don't understand what could go wrong.
server {
server_name onepage.cendrounet.com;
listen 80;
root /home/pag/workspace/test_css_platform;
location / {
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Nginx is running.
# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/nginx.service.d
└─php-fpm.conf
Active: active (running) since Fri 2017-12-22 09:48:06 CET; 10h ago
Php-fpm is running :
# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2017-12-22 09:40:29 CET; 10h ago
Php-fpm is indeed an unix socket
# ls -l /var/run/php-fpm/www.sock
srw-rw----+ 1 root root 0 déc. 22 09:40 /var/run/php-fpm/www.sock
I am running fedora, but ausearch -m avc doesn't yield anything. (In case I don't understand how selinux works, setenforce 0 hasn't yielded any better resutls. But still, I returned it on.)
Furthermore, curl -i 'http://onepage.cendrounet.com' returns
HTTP/1.1 404 Not Found
Server: nginx/1.12.1
Date: Fri, 22 Dec 2017 19:11:49 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/7.1.12
Furthermore, my user nginx belongs to my group pag.
I have set my permissions like so :
# namei -om /home/pag/workspace/css_test_platform/index.php
f: /home/pag/workspace/css_test_platform/index.php
dr-xr-xr-x root root /
drwxr-xr-x root root home
drwxr-x--x pag pag pag
drwxr-xr-x pag pag workspace
drwxrwxr-x pag pag css_test_platform
-rw-rw-r-- pag pag index.php
The configuration of php-fpm is the default one, some details picked :
user = apache
group = apache
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
Theorically, user and group should be for RPM stuff, but I still have given the pag group to apache.
What could cause a 404 error on my index ?
This was on Arch, but it is systemd related.
This solution is for use on a development machine, and for good reasons, you shouldn't run a public site from your /home folder.
I configured php-fpm and nginx to run as my user. Edit the following file, and remove the ProtectHome=true line
sudo vi /etc/systemd/system/multi-user.target.wants/php-fpm.service
Reload, and restart everything;
systemctl daemon-reload
systemctl restart nginx.service
systemctl restart php-fpm.service
You need to add try_files $uri /index.php; or similar in your location block:
location / {
try_files $uri /index.php;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
include fastcgi.conf;
}
Related
i tryed so much and followed countless guides for that problem but just cant find a solution, so i hope that you can find a problem in my configs or have a other idea what the problem could be.
Beside my planned webpage i run the AMP-Webinterface for server-administration on a supdomain amp.EXAMPLE.COM, on my debian10 server, and that always works like a charm, only my own test-php-site (see below) wont show correctly, i tested with a example html site and that works perfectly.
php8.0-fpm is installed and the only php version (had 7.3 too before and removed it already)
#######################################################
index.php
<html>
<head>
<title>PHP-Test</title>
</head>
<body>
<?php echo '<p>Hallo Welt</p>'; ?>
</body>
</html>
#######################################################
EXAMPLE.COM.conf
server {
if ($host = www.EXAMPLE.COM) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = EXAMPLE.COM) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80; listen [::]:80;
server_name EXAMPLE.COM www.EXAMPLE.COM;
root /var/www/EXAMPLE.COM;
index index.php index.html index.htm index.nginx-debian.html;
location / {
location ~* \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
try_files $uri #yii =404;
}
} }
server {
listen 443; listen [::]:443;
server_name EXAMPLE.COM www.EXAMPLE.COM;
root /var/www/EXAMPLE.COM;
index index.php index.html index.htm index.nginx-debian.html;
location / {
location ~* \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
try_files $uri #yii =404;
}
}
ssl_certificate /etc/letsencrypt/live/EXAMPLE.COM/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/EXAMPLE.COM/privkey.pem; # managed by Certbot
}
#######################################################
nginx -t
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on [::]:443, ignored
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "amp.EXAMPLE.COM" on [::]:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Nginx Error log isnt showing any errors too, except the "conflicting server name thing"
#######################################################
php8.0-fpm is installed and working ("php-fpm" cant be found by systemctl, could this be a problem?)
systemctl status php8.0-fpm
● php8.0-fpm.service - The PHP 8.0 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php8.0-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-03-16 14:08:33 UTC; 18h ago
Docs: man:php-fpm8.0(8) Main PID: 100460 (php-fpm8.0) Status: "Processes active: 0, idle: 2, > Requests: 11, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 9508) Memory: 17.6M CGroup: /system.slice/php8.0-fpm.service
├─100460 php-fpm: master process (/etc/php/8.0/fpm/php-fpm.conf)
├─100461 php-fpm: pool www
└─100462 php-fpm: pool www
Mar 16 14:08:33 localhost systemd[1]: Starting The PHP 8.0 FastCGI Process Manager... Mar 16 14:08:33 localhost systemd[1]: Started The PHP 8.0 FastCGI Process Manager.
#######################################################
tail -f /var/log/nginx/error.log
[error] 129821#129821: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 217.254.148.38, server: EXAMPLE.COM, request: "GET / HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "EXAMPLE.COM"
#######################################################
Thank you i finally found the solution! breaksdownintearsofjoy
Problem has been that fastcgi wasnt installed >_>
For my debian 10 i just did: apt-get install fcgiwrap
problem was the localhost ip it kinda didnt liked; so i just replaced "fastcgi_pass 127.0.0.1:9000;" with the complete dir of the php fpm sock "fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;"
I want to run php under nginx, I have some difficulties. I'm almost done, however, I have an error 502, I don't know why.
I have Nginx 1.18, php 7.4.x with fpm. I created a php file in: /usr/share/nginx/html/info.php, however when I am on it, I have an error 502. Here is the file I have for the default conf:
server {
listen 80;
root /usr/share/nginx/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
I have seen this line in some cases, however when I do "nginx -t" it fails.
include snippets / fastcgi-php.conf;
I looked carefully, everything works locally, everything works. I do not understand.
In your post above you have server_name example.com. Check if you have the right server name there. Also, make sure your application server is running because nginx is unable to reach that's why you are seeing 502
The problem is having more than 1 config file in /etc/php/7.4/fpm/pool.d
usr#server:/etc/php/7.4/fpm/pool.d$ ls
www.conf foor-php-fpm.conf bar-php-fpm.conf.bak
Solution
Step 1: Remove or rename any other .conf files and leave only www.conf
usr#server:/etc/php/7.4/fpm/pool.d$ sudo mv other-php-fpm.conf other-php-fpm.conf.bak2
Step 2: systemctl restart php7.4-fpm.service
Done!
user#server:~$ systemctl status php7.4-fpm.service
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-12-31 16:16:22 UTC; 6s ago
Docs: man:php-fpm7.4(8)
Process: 381508 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exited, status=0/SUCCESS)
Main PID: 381487 (php-fpm7.4)
Status: "Ready to handle connections"
Tasks: 3 (limit: 4568)
Memory: 12.1M
CGroup: /system.slice/php7.4-fpm.service
├─381487 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
├─381506 php-fpm: pool www
└─381507 php-fpm: pool www
This solution applies to php-fpm-7.2 as well.
I have been struggling lately on installing latest nginx 1.14, php 7.2.5 and mariaDB 10.3.7 on CentOS 7 on virtualbox on macOS.
Finally php is working, I have already tested php_info(), index.php, testDBconnection.php successfully and even redirecting to a /public folder.
However, when copying my Slim 3 application to folder, I get this error:
access denied
I access the log via # tail /var/log/nginx/error.log and the output is the following:
PHP message: PHP Warning: session_start(): Failed to read session data: files (path: /var/opt/remi/php72/lib/php/session) in /usr/share/nginx/html/slim3.local/bootstrap/app.php on line 5" while reading response header from upstream, client: 192.168.1.71, server: slim3.local, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "slim3.local"
2018/06/23 01:27:40 [error] 2514#2514: *5 FastCGI sent in stderr: "PHP message: PHP Warning: session_start(): open(/var/opt/remi/php72/lib/php/session/sess_1ncvjg5us9384bs0m6vo0m46k7, O_RDWR) failed: Permission denied (13) in /usr/share/nginx/html/slim3.local/bootstrap/app.php on line 5
PHP message: PHP Warning: session_start(): Failed to read session data: files (path: /var/opt/remi/php72/lib/php/session) in /usr/share/nginx/html/slim3.local/bootstrap/app.php on line 5" while reading response header from upstream, client: 192.168.1.71, server: slim3.local, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "slim3.local"
Line 5 of app.php is:
session_start();
Moreover, it looks weird to see the ip address http://192.168.1.71/ when it is actually http://192.168.1.76/
I have changed permissions in /var/opt/remi/php72/lib/php to folders session, opcache, & wsdlcache by using the following command:
# chown nginx:nginx /var/opt/remi/php72/lib/php/session
I have restarted all:
# systemctl restart php72-php-fpm
# systemctl restart nginx
Also I have tried:
# grep session.save_path /etc/opt/remi/php72/php.ini
; session.save_path = "N;/path"
; session.save_path = "N;MODE;/path"
;session.save_path = "/tmp"
; (see session.save_path above), then garbage collection does *not*
I reload the page "http://slim3.local" and I still get the same access denied error!
:(
# ls -la
returns
# ls -lah /var/opt/remi/php72/lib/php/
total 0
drwx------. 5 nginx nginx 53 jun 19 19:51 .
drwxr-xr-x. 7 root root 71 jun 19 19:51 ..
drwx------. 3 nginx nginx 46 jun 25 19:02 opcache
drwxrwx---+ 2 nginx nginx 84 jun 25 19:02 session
drwx------. 2 nginx nginx 6 may 23 01:59 wsdlcache
the www.conf file
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]
...
; RPM: apache user chosen to provide access to the same directories as httpd
;user = apache
user = nginx
; RPM: Keep a group allowed to write in log dir.
;group = apache
group = nginx
...
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
; Set listen(2) backlog.
; Default Value: 511
;listen.backlog = 511
; 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 = nobody
;listen.group = nobody
;listen.mode = 0660
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
...
; See warning about choosing the location of these directories on your system
; at http://php.net/session.save-path
php_value[session.save_handler] = files
php_value[session.save_path] = /var/opt/remi/php72/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/opt/remi/php72/lib/php/wsdlcache
php_value[opcache.file_cache] = /var/opt/remi/php72/lib/php/opcache
In the php.ini file i got:
...
cgi.fix_pathinfo=1
...
session.save_path = "/var/opt/remi/php72/lib/php/session"
...
nginx default.conf file:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
#root /usr/share/nginx/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri = 404;
include /etc/nginx/fastcgi_params;
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
my nginx virtual.conf
server {
server_name slim3.local;
root /usr/share/nginx/html/slim3nc.local/public;#without this line, it throws NOT FOUND
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri = 404;
include /etc/nginx/fastcgi_params;
root /usr/share/nginx/html/slim3nc.local/public;#Esta carpeta influye más
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include /etc/nginx/fastcgi_params;
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/slim3nc.dev$fastcgi_script_name;
}
}
and the command
# lsattr /var/opt/remi/php72/lib/php/session
returns
---------------- /var/opt/remi/php72/lib/php/session/sess_1ncvjg5us9384bs0m6vo0m46k7
---------------- /var/opt/remi/php72/lib/php/session/sess_923979fqgr7r807majmn114vuk
Testing sestatus
# sestatus
It returns
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
And if I apply
# setenforce 0
it returns
# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
Moreover, I have tried to change the setup in path for cache right on Slim3 container settings and nothing works :(
$container['view'] = function ($container) {
$view = new \Slim\Views\Twig(__DIR__ . '/../resources/views', [
'cache' => false,/*__DIR__ .'/../cache/views', *//* todo 'path/to/cache' on production, we need to set up a directory to cache the views*/
'debug' => false, /*todo Turn this off in production*/
]);
...
return $view;
};
I still get the message in a blank page
access denied
This slim 3 web app I got does not work in any server: centOS 7 production, laravel homestead, ubuntu 16, ... it simply doesn't work!!!
What am I missing?
How do I fix this??
-> Meanwhile I am using Laravel ...
On my vagrant box , centtos 7, i had installed php7.0.3 and nginx 1.9.12. the php config www.conf. this file in the /usr/local/php/etc/php-fpm.d/ directory, Its configuration like this
user = www
group = www
;listen = /tmp/php-fpm.sock
listen = 127.0.0.1:9000
listen.owner = www
listen.group = www
and the nginx config. the file vm.demo.com.conf in the /usr/local/nginx/conf/vhost/ directory. Its configuration like this
server {
listen 80;
server_name vm.demo.com;
index index.html index.htm index.php;
root /data/wwwroot/demo;
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ .*\.(php|php5)?$ {
#fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
access_log logs/demo.log main;
}
in the nginx conf, if i use fastcgi_pass 127.0.0.1:9000 and the php-fpm.conf listen 127.0.0.1:9000, They are working properly
bug if i use the socket configuration:
php www.conf
user = www
group = www
listen = /tmp/php-fpm.sock
listen.owner = www
listen.group = www
nginx vm.demo.com.conf
location ~ .*\.(php|php5)?$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
the nginx show 502 Bad gateway. in the nginx error.log show this.
2016/03/14 21:17:04 [crit] 4208#0: *5 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while
connecting to upstream, client: 192.168.1.101, server: vm.demo.com, request: "GET /test.php HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "vm.demo.com"
2016/03/14 21:17:04 [crit] 4208#0: *5 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while
connecting to upstream, client: 192.168.1.101, server: vm.demo.com, request: "GET /test.php HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "vm.demo.com"
2016/03/14 21:18:01 [crit] 4208#0: *5 connect() to unix:/tmp/php-fpm.sock failed (2: No such file or directory) while
connecting to upstream, client: 192.168.1.101, server: vm.demo.com, request: "GET /test.php HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "vm.demo.com"
when i check the /tmp/php-fpm.sock file, it's existing
[root#vbox1 vhost]# ll /tmp/php-fpm.sock
srw-rw---- 1 www www 0 Mar 14 21:06 /tmp/php-fpm.sock
this are php and nginx running status:
[root#vbox1 vhost]# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/etc/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-03-14 21:06:27 CST; 42min ago
Process: 4189 ExecStop=/bin/kill -SIGINT $MAINPID (code=exited, status=0/SUCCESS)
Main PID: 4198 (php-fpm)
CGroup: /system.slice/php-fpm.service
├─4198 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
├─4199 php-fpm: pool www
└─4200 php-fpm: pool www
Mar 14 21:06:27 vbox1 systemd[1]: Started The PHP FastCGI Process Manager.
Mar 14 21:06:27 vbox1 systemd[1]: Starting The PHP FastCGI Process Manager...
[root#vbox1 vhost]# systemctl status nginx.service
● nginx.service - nginx
Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-03-14 21:06:35 CST; 42min ago
Process: 4180 ExecStop=/usr/local/nginx/sbin/nginx -s quit (code=exited, status=0/SUCCESS)
Process: 4206 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 4207 (nginx)
CGroup: /system.slice/nginx.service
├─4207 nginx: master process /usr/local/nginx/sbin/nginx
├─4208 nginx: worker process
└─4209 nginx: worker process
Mar 14 21:06:35 vbox1 systemd[1]: Starting nginx...
Mar 14 21:06:35 vbox1 systemd[1]: Started nginx.
Can someone help me? If anyone encountered the same problem
I have met the same problem.
And I just change the socket path to another directory but '/tmp',
Then everything goes OK.
Basically, the problem arises with ONE process (php-fpm) setting up the sock in the /tmp path, but it would not be visible by ANOTHER process (nginx).
There is a setting in the service config, which would block files created by different process, even though using the same user.
Find your service config file (ex: /etc/systemd/system/myapp.service) and then on add this setting: PrivateTmp=No to both your services (php and nginx).
[Service]
...
PrivateTmp=No
more info about systemd units here:
https://www.freedesktop.org/software/systemd/man/systemd.unit.html
I have found a config (php5) that continues to use the unix socket and does not involve editing any other config files (except the nginx default site file).
location ~ \.php$ {
fastcgi_pass unix:/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# \Add following to use sqlite as db.
fastcgi_param DB_CONNECTION sqlite;
}
Note:- the unix socket is not at /run/php/ (though it is for php7).
The include fastcgi_params; is required to prevent the php file downloading instead of being interpreted.
For completeness the following is my entire default file.
index index.php index.html index.htm;
server {
listen 80;
server_name sponk.co.uk;
rewrite_log on;
root /vagrant/public_html;
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
fastcgi_pass unix:/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
You need to change the listen.owner and the listen.group
listen.owner = nginx
listen.group = nginx
In my case in this file: /etc/php-fpm.d/www.conf
The socket must be the same in you nginx block (like vhost in apache). I also moved the socket under /var/sockets
You could try changing user in /usr/local/php/etc/php-fpm.d/www.conf to nginx and restart service.
user = nginx
group = nginx
listen = /tmp/php-fpm.sock
For all those who use Homestead inside Vagrant:
I solved simply reloading vagrant with provision flag:
from project root:
cd Homestead
and then:
vagrant reload --provision
in this manner recompile all configurations
I had this problem, you can do this:
chmod 777 yourpath/php-fpm.sock
This worked for me.
I have a Debian 7.3 installation in a VM that I am practising installing Nginx and php5-fpm on. I got the Nginx working, by assigning it a manual port of :8080 and that points to /var/www/ for data and in that directory is an index.html and info.php file.
The config file for my Nginx is located at /etc/nginx/conf.d/default.conf and looks like this:
server {
listen 8080;
root /var/www;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
I have tried changing fastcgi_pass both ways:
fastcgi_pass 127.0.0.1:9000;
and also as:
fastcgi_pass unix:/var/run/php5-fpm.sock;
In my /etc/php5/fpm/pool.d/www.conf file I have the following configuration:
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9000
;listen = /var/run/php5-fpm.sock
Here too, I have uncommented the line to match in the Nginx default.conf file.
In my php.ini file I have edited it so that it shows cgi.fix_pathinfo = 0 as required by most of the guides I have seen.
When I try to load nginx, it runs OK. When I try to run php5-fpm this is what happens:
root#debianx86:/# /etc/init.d/php5-fpm status
[FAIL] php5-fpm is not running ... failed!
root#debianx86:/# /etc/init.d/php5-fpm reload
[ ok ] Reloading PHP5 FastCGI Process Manager: php5-fpm.
root#debianx86:/# /etc/init.d/php5-fpm restart
[FAIL] Restarting PHP5 FastCGI Process Manager: php5-fpm failed!
root#debianx86:/# /etc/init.d/php5-fpm start
root#debianx86:/# /etc/init.d/php5-fpm status
[FAIL] php5-fpm is not running ... failed!
root#debianx86:/#
I then open up any of the browsers on my VM and point them to either 127.0.0.1:8080 or localhost:8080 and I get the custom index.html loading that I made and it works! So I then try to load theinfo.php file and I get presented with a 404 Not Found - nginx/1.4.4.
I don't understand what I'm doing wrong. Is there something I'm missing from all this?
I installed nginx from sudo apt-get -y install nginx and sudo apt-get -y install php5-fpm too. Any dependencies they required would have been installed along with that.
Is there a script that I can run on a fresh install of Debian 7.3 that someone has got that will install it properly for me, and make all the modifications so that nginx and php5-fpm are up and running? I've looked over many of the websites with the instructions and I seem to be doing pretty much everything they do, except for the default-sites and enabled-sites, as neither of those folders exist for me, and I don't want to run my virtual hosts like that. I will run them with their own servers listed in the default.conf file.
EDIT: I have even tried following this article at DigitalOcean and it still doesn't work.
EDIT #2: I also did chown -R www-data:www-data /var/www to ensure that the user and group match the information in the www.conf file. I also tried by changing it back to the original root:root specs too. Still nothing.
I think maybe port 9000 is already being used, so php5-fpm can't bind with that port and fails to start.
in the fpm pool settings swap the line of port 9000 with the line with the sock file, then try to start php5-fpm like you were doing, if it works then all you need is to update the nginx configuratuin to proxy pass to the sock file instead of the port.