Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need PHP-FPM 7.3 help with nginx and debian 9 WordPress

  • SOLVED

I just setup a new Debian 9 VPS. Also installed PHP 7.3 and PHP FPM 7.3.

php -v at the command line shows:


PHP 7.3.3-1+0~20190307202245.32+stretch~1.gbp32ebb2 (cli) (built: Mar 7 2019 20:22:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.3-1+0~20190307202245.32+stretch~1.gbp32ebb2, Copyright (c) 1999-2018, by Zend Technologies


Normally, setting up my nginx server block files to use php7.0-fpm is a walk in the park. But for some reason, on this latest Debian 9 and PHP 7.3 it's proven to be a royal pain. I've spent all afternoon Googling and troubleshooting, and I'm getting nowhere fast.

My nginx log is reporting this:

2019/04/09 21:32:51 [emerg] 29565#29565: "location" directive is not allowed here in /etc/nginx/conf.d/oilygurus.ch.conf:31


My server block file is:

server {
server_name oilygurus.ch www.oilygurus.ch;

location / {
root /var/www/oilygurus.ch/public_html;
index index.php;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/oilygurus.ch/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/oilygurus.ch/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = www.oilygurus.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = oilygurus.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;
server_name oilygurus.ch www.oilygurus.ch;
return 404; # managed by Certbot

}


I have this set in my php.ini:

cgi.fix_pathinfo=0;

I have this set in my www.conf file:

listen = 127.0.0.1:9000

Here's my nginx.conf file:


user nginx;
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;
}


And finally, my php-fpm.conf file:

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

[global]
pid = /run/php/php7.3-fpm.pid
error_log = /var/log/php7.3-fpm.log
include=/etc/php/7.3/fpm/pool.d/*.conf


I'm totally at a loss on this. Thanks for any suggestions!

Answers (3)

2019-04-09

Rempty answers:

check your file
oilygurus.ch.conf
and find if the
location is inside a server like

server {
location / {
..........
}
location ~ \.php$ {
......
}
}


Kyler Boudreau comments:

Thanks - you can see my full server block file for oilygurus.cs.conf above.


Rempty comments:

can you try removing this part?

server {
if ($host = www.oilygurus.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = oilygurus.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;
server_name oilygurus.ch www.oilygurus.ch;
return 404; # managed by Certbot

}

2019-04-09

Cesar Contreras answers:

Please try this configuration for your server and do not forget to restart your services (NGINX, PHP-FPM) after making the changes.

server {
#the server name
server_name oilygurus.ch www.oilygurus.ch;

# The location of our project's public directory.
root /var/www/oilygurus.ch/public_html;;

# Index para sistemas PHP.
index index.php;

location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/oilygurus.ch/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/oilygurus.ch/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
if ($host = www.oilygurus.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = oilygurus.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;
server_name oilygurus.ch www.oilygurus.ch;
return 404; # managed by Certbot

}

2019-04-10

Echeverri answers:

Try removing the block of code that the log tells you