PHP-FPM Integration driving me mad
Simon Hönscheid
mailinglisten at simonhoenscheid.de
Sat Jul 30 20:44:55 UTC 2016
Hello List,
due to a Server move, I was setting up a new nginx installation. Some of
the pages need php. So far nothing new. When I start adding
SCRIPT_FILENAME to the php location, it ends up that the script is no
longer found.
==> /var/log/nginx/www.example.com-error.log <==
2016/07/30 21:21:15 [error] 5546#5546: *1 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: xx.xxx.xxx.xxx, server: www.example.com, request: "GET /info.php
HTTP/1.1", upstream: "fastcgi://unix:/var/run/fpmpool-www.socket:",
host: "www.example.com"
Do I leave it out, the script is handled but no output is retuned.(blank
white page) I'm debugging this now for hours and dont get any usable
result. Any help is appreciated.
Nginx: 1.10.1
PHP: 5.6.24
OS: Debian 8.5
nginx conf:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
worker_rlimit_nofile 40960;
events {
use epoll;
worker_connections 4096;
}
http {
proxy_intercept_errors on;
fastcgi_intercept_errors on;
log_format main '';
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 5;
sendfile on;
keepalive_requests 150;
include /etc/nginx/sites-enabled/*;
include /etc/nginx/mime.types;
open_file_cache max=40960 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml application/xml
text/javascript application/x-javascript;
gzip_disable "MSIE [1-6]\.";
proxy_buffers 64 32k;
}
the server itself:
server {
server_name www.example.com;
listen xxx.xxx.xxx.xx:443 ssl http2;
access_log /var/log/nginx/www.example.com-access.log combined;
error_log /var/log/nginx/www.example.com-error.log notice;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_ciphers
EECDH+AESGCM:EDH+AESGCM:EECDH:EDH:MD5:!RC4:!LOW:!MEDIUM:!CAMELLIA:!ECDSA:!DES:!DSS:!3DES:!NULL;
charset utf-8;
index index.php index.html;
client_max_body_size 50M;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:5m;
ssl_dhparam /etc/nginx/dhparam.pem;
ssl_certificate
/opt/letsencrypt_certificates/nginx/www.example.com/fullchain.pem;
ssl_certificate_key
/opt/letsencrypt_certificates/nginx/www.example.com/privkey.pem;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
root /var/www/www.example.com;
}
location ~ \.php$ {
fastcgi_buffers 16 4k;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/fpmpool-www.socket;
include fastcgi_params;
}
}
PHP fpm config
[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
syslog.facility = daemon
syslog.ident = php-fpm
log_level = notice
emergency_restart_threshold = 0
emergency_restart_interval = 0
process_control_timeout = 0
include=/etc/php5/fpm/pool.d/*.conf
PHP pool config:
listen = /var/run/fpmpool-www.socket
listen.backlog = -1
listen.owner = www-data
listen.group = www-data
user = www-data
group = www-data
pm = dynamic
pm.max_children = 25
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests = 500
pm.status_path = /fpm-status
ping.response = pong
request_terminate_timeout = 60s
request_slowlog_timeout = 0
slowlog = /var/log/php-fpm/www-slow.log
rlimit_files = 32000
rlimit_core = unlimited
catch_workers_output = yes
old PHP Location, on old server was:
location ~* \.php$ {
fastcgi_buffers 16 4k;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_URI http://$http_host$request_uri;
fastcgi_param SCRIPT_URL $request_uri;
fastcgi_param SERVER_NAME $http_host;
}
Kind Regards
Simon
More information about the nginx
mailing list