I have pointed my domain rohanpatra.ga to my server and installed nginx. I am currently running two domains on the server, rohanpatra.ga, and meetsecured.tk. MeetSecured is a blockchain video conferencing platform based on Jitsi Meet, and it seems to be running fine. But, when I go to rohanpatra.ga, it just goes to the default nginx page.
I've created the config file:
sites-available directory
config file content
server {
listen 80;
listen [::]:80;
root /var/www/rohanpatra.ga;
index index.php index.html index.htm;
server_name your_domain;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
And symlinked the file to the sites-enabled folder:
sites-enabled directory
Here is the root directory of the site and the content of the one file index.php:
/var/www/rohanpatra.ga directory
index.php
<?php
phpinfo();
?>
as requested:
root#debian-8gb-hel1-1:~# ps auxww |grep nginx
reponse
root 5874 0.0 0.1 70944 9032 ? Ss May30 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 9129 0.0 0.1 71228 9516 ? S 21:52 0:00 nginx: worker process
www-data 9130 0.0 0.0 71228 6344 ? S 21:52 0:00 nginx: worker process
www-data 9131 0.0 0.0 71228 6344 ? S 21:52 0:00 nginx: worker process
www-data 9132 0.0 0.0 71228 6344 ? S 21:52 0:00 nginx: worker process
root 10356 0.0 0.0 6144 888 pts/0 S+ 22:29 0:00 grep nginx
According to Nginx documentation you have misconfigured server_name parameter in your config.
Correct config should look like:
server {
listen 80;
server_name rohanpatra.ga;
root /var/www/rohanpatra.ga;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
And be sure that this FQDN rohanpatra.ga is correctly resolving on the server itself.
You can check by typing: nslookup rohanpatra.ga at server console.
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 have upgraded with success my ubuntu server from php7.0 to php7.2
I am using Nginx with php-fpm. Although php -v output is:
PHP 7.2.11-4+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 4 2018 05:10:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.5, Copyright (c) 2002-2018, by ionCube Ltd.
with Zend OPcache v7.2.11-4+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I noticed that Nginx still runs with php-fpm7.0.
I checked and both php-fpm 7.0 & 7.2 are running.
My /etc/nginx/conf.d/mysite.com.conf doesn't include
location ~* .php$
line.
Output of
find / ( -iname "php.ini" -o -name "www.conf" )
is
/etc/php/7.0/apache2/php.ini
/etc/php/7.0/fpm/pool.d/www.conf
/etc/php/7.0/fpm/php.ini
/etc/php/7.0/cli/php.ini
/etc/php/7.2/fpm/pool.d/www.conf
/etc/php/7.2/fpm/php.ini
/etc/php/7.2/cli/php.ini
Also I don't have any /etc/nginx/conf.d/mysite.com.conf file
I only have global_locations_ssl.conf.inc inside /etc/nginx/conf.d/
Output of
ps -aux | grep nginx
is
root 3123 0.0 0.0 37944 4192 ? Ss Nov05 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 3124 0.0 0.0 37944 8416 ? S Nov05 0:54 nginx: worker process
www-data 3125 0.0 0.0 37944 8500 ? S Nov05 0:58 nginx: worker process
www-data 3126 0.0 0.0 37944 8552 ? S Nov05 2:04 nginx: worker process
www-data 3127 0.0 0.0 37944 8588 ? S Nov05 1:04 nginx: worker process
www-data 3128 0.0 0.0 37944 8668 ? S Nov05 1:10 nginx: worker process
www-data 3129 0.0 0.0 37944 8536 ? S Nov05 1:27 nginx: worker process
root 22931 0.0 0.0 13348 916 pts/0 R+ 12:50 0:00 grep --color=auto nginx
So my Nginx master process runs as root.
What should I check to fix this?
you can find solution full solution in https://linode.com/docs/web-servers/nginx/serve-php-php-fpm-and-nginx/
Depending on your distribution and PHP version, the PHP configuration files will be stored in different locations. This guide is using PHP 7.0 from Ubuntu’s repositories on Ubuntu 16.04 as an example, and the
`/etc/php/7.0/fpm/pool.d/www.conf and /etc/php/7.0/fpm/php.ini`
files are what we’ll be modifying.
Find those full file paths using a find command:
`find / \( -iname "php.ini" -o -name "www.conf" \)`
The output should look similar to:
`root#localhost:~# find / \( -iname "php.ini" -o -name "www.conf" \)
/etc/php/7.0/fpm/php.ini
/etc/php/7.0/fpm/pool.d/www.conf
/etc/php/7.0/cli/php.ini
`
The listen.owner and listen.group variables are set to www-data by default, but they need to match the user and group NGINX is running as. If you installed NGINX using our Getting Started with NGINX series, then your setup will be using the nginx user and group. You can verify with:
`ps -aux | grep nginx`
The output should be similar to:
`
root#localhost:~# ps -aux | grep nginx
root 3448 0.0 0.0 32500 3516 ? Ss 18:21 0:00 nginx: master process / usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 3603 0.0 0.0 32912 2560 ? S 18:24 0:00 nginx: worker process
nginx 3604 0.0 0.0 32912 3212 ? S 18:24 0:00 nginx: worker process
`
This shows the NGINX master process is running as root, and the worker processes are running as the nginx user and group. Change the listen variables to that:
`
sed -i 's/listen.owner = www-data/listen.owner = nginx/g' /etc/php/7.0/fpm/pool.d/www.conf
sed -i 's/listen.group = www-data/listen.group = nginx/g' /etc/php/7.0/fpm/pool.d/www.conf
`
When pairing NGINX with PHP-FPM, it’s possible to return to NGINX a .php URI that does not actually exist in the site’s directory structure. The PHP processor will process the URI, and execute the .php file, because its job is to process anything handed to it by NGINX. This of course presents a security problem.
It’s important limit what NGINX passes to PHP-FPM so malicious scripts can’t be injected into return streams to the server. Instead, the request is stopped, possibly then resulting in a 404. There are multiple ways to do this (see the NGINX wiki) but here we chose to specify the setting in PHP-FPM rather than in NGINX’s configuration.
`sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/7.0/fpm/php.ini`
You’ll notice that ;cgi.fix_pathinfo=1 is commented out by default. Setting it to 0 and uncommenting it will enforce the configuration should there be any upstream changes in the default value in the future.
Restart PHP-FPM to apply the changes:
`systemctl restart php7.0-fpm.service`
Configure the NGINX Server BlockPermalink
Again pulling from Part 1 of our NGINX series, we’ll start with a basic Server Block for a static HTTP page being served from /var/www/example.com. Replace example.com with your site’s domain or IP address, and the root directive with your site’s root directory.
`/etc/nginx/conf.d/example.com.conf
`server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html;
}
`
To the Server Block above, add a location block containing the PHP directives. You should then have:
/etc/nginx/conf.d/example.com.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html;
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
This is just a bare minimum to get PHP-FPM working and you will want to configure it further for your specific needs. Some further points about the configuration above:
The location ~* \.php$ means that NGINX will apply this configuration to all .php files (file names are not case sensitive) in your site’s root directory, including any subdirectories containing PHP files.
The * in the ~* \.php$ location directive indicates that PHP file names are not case sensitive. This can be removed if you prefer to enforce letter case.
The fastcgi_pass location must match the listen = value in /etc/php/7.0/fpm/pool.d/www.conf. It is preferable for performance reasons for PHP-FPM to listen on a UNIX socket instead of a TCP address. Only change this if you require PHP-FPM use network connections.
Using $document_root in the SCRIPT_FILENAME parameter instead of an absolute path is preferred by NGINX’s documentation.
Here’s a variation of the location block above. This includes an if statement which disallows the FPM to process files in the /uploads/ directory. This is a security measure which prevents people from being able to upload .php files to your server or application which the FastCGI process manager would then execute.
This only applicable if you allow users to upload or submit files to your site. Change the name of the directory from uploads to whatever suits your need.
/etc/nginx/conf.d/example.com.conf
location ~* \.php$ {
if ($uri !~ "^/uploads/") {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
Reload NGINX:
nginx -s reload
I found the solution.
In my /etc/nginx/sites-enabled/my-site.conf had a line
upstream fastcgi_backend {
server 127.0.0.1:9000;
}
Nginx was configure without the
location ~* .php$
line.
So you don't have to change configuration every time you change php versions.
My problem was that I didn't checked that php-fpm7.0 was running at socket 9000.
The solution was to change in php.ini inside php-fpm7.2 to run at socket 9000
So I've got a Ubuntu server that I'm trying to restore from a backup. And when a dummy PHP version page I get 502 Bad Gateway. What have I tried to fix it? Quite a few things including the answers from this related question - nginx 502 bad gateway
This is my default config with Ubuntu
server {
listen 80;
# listen [::]:81 ipv6only=on default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name localhost;
location ~* \.(js|css|png|jpg|jpeg|gif|ico|html)$ {
expires max;
}
location / {
try_files $uri $uri.php $uri.php/$args /index.php?q=$uri&$args $uri/ =404;
index index.php index.html index.htm;
rewrite ^(.*)$ /$1.php;
}
location /phpmyadmin {
index index.php;
try_files $uri $uri/ =404;
auth_basic "Admin Login";
auth_basic_user_file /etc/nginx/pma_pass;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
EDIT:
Here's what I think is the relevant part of the log
2017/08/11 13:18:13 [error] 27759#0: *270 connect() failed (111: Connection refused) while connecting to upstream, client: 66.61.18.112, server: domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "[IP ADDRESS]", referrer: "http://[IP ADDRESS]/phpmyadmin/index.php"
EDIT 2:
Here's the result when I run ps aux | grep php-fpm:
mre 21685 0.0 0.0 11756 932 pts/0 S+ 10:42 0:00 grep --color=auto php-fpm
root 32721 0.0 1.0 269300 11168 ? Ss Aug11 0:30 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data 32724 0.0 0.4 269300 4540 ? S Aug11 0:00 php-fpm: pool www
www-data 32725 0.0 0.4 269300 4540 ? S Aug11 0:00 php-fpm: pool www
Edit 3:
Here's what's uncommented out of my php-fpm.conf
[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /var/run/php5-fpm.pid
; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php5-fpm.log
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf
Edit 4:
Here's what's uncommented from my www.conf:
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
Edit 5:
My nginx log after I try to go to index.php:
[error] 29393#0: *23 connect() failed (111: Connection refused) while connecting to upstream, client: [Computer IP Address], server: [Subdomain.domain.com], request: "GET /favicon.ico HTTP/1.1", upstream:"http://127.0.0.1:8080/favicon.ico", host: [Server IP], referrer: "http://[Server IP]/index.php"
So I checked out my nginx config and found these lines:
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
Then I went to /etc/nginx/conf.d/*.conf and saw that in the servers.conf file, there was a config for a sub domain that I planned on using but won't anymore so I deleted it. This was a big part of the problem because nginx was looking in this config first and that's why the errors included this subdomain.
As for the php problems, I switched my config to fastcgi_pass unix:/run/php/php7.0-fpm.sock; and that seems to have fixed the problem.
Try to replace
fastcgi_pass unix:/var/run/php5-fpm.sock;
in your nginx config to
fastcgi_pass 127.0.0.1:9000;
Because if your PHP-FPM config you use TCP instead of socket (it's OK).
You have to change this line
from:
listen = 127.0.0.1:9000
to:
listen = /var/run/php5-fpm.sock
in your www.conf file
Don't forget to restart php.
Explanation:
If you look at your nginx virtual host fastcgi_pass parameter
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
you'll see that you are pointing processing of php files to php5-fpm socket but in your www.conf file php is listening port 9000 which is why you should change it to /var/run/php5-fpm.sock
I am installing a Nginx with PHP7 server on CentOS and like a lot of users I have the 502 bad gateway issue. I read all night long pages trying to solve my issue but I still have the same issue. I will explain it here so if somebody have some idea of what is going on, I would appreciate some help :-)
First of all the error logs from nginx and php-fpm. I use the "socket method" and I tried with the "network method" using 127.0.0.1:9000 but it didn't change anything... So I rollbacked the configuration. According to the logs, it does not seem to be an permission denied issue.
Note: The html pages are OK, the issue only appears with php pages.
nginx.log
2016/04/18 22:59:22 [error] 4705#0: *47 upstream sent invalid status "20 Site temporarily unavailable" while reading response header from upstream, client: 86.253.24.233, server: testvps.balusson.net, request: "GET /phpMyAdmin/ HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "testvps.balusson.net"
2016/04/18 23:46:09 [error] 6115#0: *95 upstream sent invalid status "20 Site temporairement indisponible" while reading response header from upstream, client: 86.253.24.233, server: testvps.balusson.net, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "testvps.balusson.net"
But I don't see anything in the PHP-FPM logs
[root#vps263501 ~]# tail /var/log/php-fpm/error.log
[18-Apr-2016 21:46:48] NOTICE: fpm is running, pid 8008
[18-Apr-2016 21:46:48] NOTICE: ready to handle connections
[18-Apr-2016 21:59:41] NOTICE: Terminating ...
[18-Apr-2016 21:59:41] NOTICE: exiting, bye-bye!
[18-Apr-2016 22:11:12] NOTICE: fpm is running, pid 2886
[18-Apr-2016 22:11:12] NOTICE: ready to handle connections
[18-Apr-2016 22:11:15] NOTICE: Terminating ...
[18-Apr-2016 22:11:15] NOTICE: exiting, bye-bye!
[18-Apr-2016 22:11:15] NOTICE: fpm is running, pid 2913
[18-Apr-2016 22:11:15] NOTICE: ready to handle connections
My configuration file is quite simple:
/etc/nginx/sites-available/maisonrt2012.conf
server {
listen 80;
server_name testvps.balusson.net;
root /var/www/maisonrt2012/public_html;
index index.html index.htm index.php;
# Pass PHP scripts on to PHP-FPM
location ~* \.php$ {
try_files $uri /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/run/php-fpm/www.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
location /phpMyAdmin {
root /usr/share/;
index index.html index.htm index.php;
}
}
The default.conf is set to the unix socket according to my sites-available configuration file
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /var/www/maisonrt2012/public_html/;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
In the nginx.conf file, the user is specified as nginx;
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
My PHP-FPM config file is as below
/etc/php-fpm.d/www.conf
; Start a new pool named 'www'.
[www]
user = nginx
group = nginx
;listen = 127.0.0.1:9000
listen = /run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
;listen.acl_users = nobody
;listen.acl_groups =
listen.allowed_clients = 127.0.0.1
The location of www.sock is OK with the nginx user and rights
[root#vps263501 ~]# ls -l /run/php-fpm/
total 0
srw-rw---- 1 nginx nginx 0 Apr 18 22:11 www.sock
I added the two following lines in the file /etc/nginx/fastcgi_params because they were missing (I found this on a different topic)
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
But I still have my issue.
I'm stuck now so if anybody have an idea I would appreciate :-)
Of course, PHP and Nginx are well started with the proper user
[root#vps263501 ~]# ps aux | grep php
root 2913 0.0 0.3 317080 6464 ? Ss Apr18 0:00 php-fpm: master process (/etc/php-fpm.conf)
nginx 2914 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2915 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2916 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2917 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2918 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 3705 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
root 9259 0.0 0.0 103304 892 pts/0 S+ 00:09 0:00 grep php
[root#vps263501 ~]# ps aux | grep nginx
nginx 2914 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2915 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2916 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2917 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 2918 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
nginx 3705 0.0 0.4 319436 8460 ? S Apr18 0:00 php-fpm: pool www
root 4168 0.0 0.1 45556 2140 ? Ss Apr18 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 6115 0.0 0.1 45560 2324 ? S Apr18 0:00 nginx: worker process
root 9261 0.0 0.0 103304 892 pts/0 S+ 00:09 0:00 grep nginx
It might be trivial but I have to admit that I'm confused...
Thanks for your help !
Change socket to 127.0.0.1:9000 in php-fpm and the restart php-fpm.
Then try the following settings in your nginx website conf:
location / {
root /var/www/maisonrt2012/public_html;
index index.php index.html index.htm;
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;
}
#error_page 404 404.html;
}
restart nginx and try it out. Don't forget: www-data may need read and execute Permission to your php files.
Had the same issue. I tried it with brute forcing :P.
Maybe this helps you out.
In case anyone else browsing StackOverflow hits this issue again, I can see that this sort of thing is mentioned in many places, e.g.
https://forum.nginx.org/read.php?3,129805,129811
https://forum.directadmin.com/threads/php-fpm-5-6-and-7-0-error-restart-every-minute.54709/
There are multiple possible causes, but I did find one that caused the issue in our system. I had monit set up to restart processes if they failed. I had a custom monit config file that looked for the php-fpm socket. We updated php-fpm from PHP 7.3 to 7.4 and the name of the socket file changed. So monit decided that php-fpm wasn't running and restarted it every minute. Changing the monit config file fixed the problem.
When requesting http://server-ip the default "Welcome to nginx" page is returned.
When requesting http://server-ip/phpinfo.php 404 is returned. No errors in the error log, but GET 404 in access log
If location ~ \.php$ is removed from the conf then phpinfo.php is downloaded as a file when requested
setup
apt-get install nginx
apt-get install php5-fpm php5-mysqlnd
conf
server {
listen 80;
server_name localhost;
location / {
root /var/www;
index index.php index.html index.htm;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
php cli
This works as expected
php -f /var/www/phpinfo.php
php-fpm
# ps aux | grep php-fpm
root 1555 0.0 0.1 183508 20976 ? Ss 16:20 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data 1557 0.0 0.0 183508 7152 ? S 16:20 0:00 php-fpm: pool www
www-data 1558 0.0 0.0 183508 7152 ? S 16:20 0:00 php-fpm: pool www
root 1932 0.0 0.0 12720 2080 pts/0 S+ 16:23 0:00 grep php-fpm
nginx version
# nginx -v
nginx version: nginx/1.8.0
PHP doesn't integrate with nginx the same way it does with Apache. You'll need to launch the PHP daemon separately.
sudo service php5-fpm restart
See here for more details.
After using the conf files from nginx 1.6.3 it works :)