Open Sil68 opened 9 years ago
@Sil68 I came across this randomly. The problem is the part of conf.d/php_fpm_status_vhost.conf
which does include snippets/fastcgi-php.conf;
- the latter file is supposed to operate on actual .php files, not special virtual URLs served by FPM itself.
Hi,
I'm in the process of setting up & configuring nginx on my Raspberry Pi running Raspbian/Debian "Jessie". Issue at hand is, that even after scouting The Net, trying out various hints, starting from scratch, using perusio's brilliant work as the foundation, I'm still failing pretty badly at even getting the very basics in terms of php working properly. :(
Software +----------------------------------------------------------------------+ :: linux armv7l 4.0.9-v7+ (debian "Jessie") :: nginx 1.9.4 :: php/php-fpm 5.6.9 :: mysql 5.5.44 +----------------------------------------------------------------------+
directory structure +----------------------------------------------------------------------+ / +-data +-www | +-apps | +-cgi-bin | +-downoad | +-htdocs | +-images | +-sites | | +-my.host.local | | | +-apps | | | | +-drupal7 | | | | +-drupal8 | | | | +-piwik | | | | +-phpmyadmin | | | | +-suitecrm | | | | +-sugarcrm | | | +-cgi-bin | | | +-downoad | | | +-htdocs | | | +-images | | | +-tmp | | | +-tools | | | +-upload | | +-my.host2.local | | +-my.host3.local | +-tmp | +-tools | +-upload ... +----------------------------------------------------------------------+
php-fpm (pool) configuration +----------------------------------------------------------------------+ [www] user = www group = www listen = /var/run/php-fpm/www.php5-fpm.sock listen.owner = www listen.group = www pm = dynamic pm.max_children = 50 pm.start_servers = 3 pm.min_spare_servers = 3 pm.max_spare_servers = 10 pm.status_path = /phpfpm-status ping.path = /phpfpm-ping ping.response = phpfpm-pong access.log = /var/log/php-fpm/$pool.access.log slowlog = /var/log/php-fpm/$pool.log.slow +----------------------------------------------------------------------+
nginx configuration
nginx.conf +----------------------------------------------------------------------+ user www www; error_log /var/log/nginx/error.log; pid /var/run/nginx/nginx.pid; worker_rlimit_nofile 1024;
events { worker_connections 512; multi_accept on; } # evnets
http { include mime.types; default_type application/octet-stream;
} # http +----------------------------------------------------------------------+
my.host.local.conf +----------------------------------------------------------------------+ server { listen 192.168.5.50:80; # IPv4 return 301 $scheme://my.host.local$request_uri; } # server domain return.
server { server_name my.host.local; listen 192.168.5.50:80; limit_conn arbeit 32;
location ~ .php$ {
include snippets/fastcgi-php.conf;
include snippets/fastcgi_pass.conf;
}
location / {
try_files $uri $uri/ =404;
}
} # HTTP server +----------------------------------------------------------------------+
conf.d/fastcgi.conf +----------------------------------------------------------------------+ include conf.d/fastcgi_params; fastcgi_buffers 256 4k; fastcgi_intercept_errors on; fastcgi_read_timeout 14400; fastcgi_index index.php; fastcgi_hide_header 'X-Drupal-Cache'; fastcgi_hide_header 'X-Generator'; +----------------------------------------------------------------------+
conf.d/fastcgi.conf +----------------------------------------------------------------------+ fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REDIRECT_STATUS 200; fastcgi_param HTTPS $fastcgi_https if_not_empty; +----------------------------------------------------------------------+
conf.d/upstream_phpcgi_unix.conf +----------------------------------------------------------------------+ upstream phpcgi { least_conn; server unix:/var/run/php-fpm/www.php5-fpm.sock; keepalive 5; } upstream www { server unix:/var/run/php-fpm/www.php5-fpm.sock; } +----------------------------------------------------------------------+
conf.d/php_fpm_status_allowed_hosts.conf +----------------------------------------------------------------------+ geo $dont_show_fpm_status { default 1; 127.0.0.1 0; 192.168.0.0/16 0; } +----------------------------------------------------------------------+
conf.d/blacklist.conf +----------------------------------------------------------------------+ map $http_user_agent $bad_bot { default 0; ~*^Lynx 0; # Let Lynx go through libwww-perl 1; ~(?i)(httrack|htmlparser|libwww) 1; }
map $http_referer $bad_referer { default 0; ~(?i)(adult|babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|webcam|zippo|casino|replica) 1; }
geo $bad_referer { 127.0.0.1 0; 192.168.0.0/16 0; } +----------------------------------------------------------------------+
apps.d/drupal/map_cache.conf +----------------------------------------------------------------------+ map $uri $no_cache_ajax { default 0; /system/ajax 1; /drupal/system/ajax 1; /drupal8/system/ajax 1; } map $http_cookie $no_cache_cookie { default 0; ~SESS 1; # PHP session cookie } map $no_cache_ajax$no_cache_cookie $no_cache { default 1; 00 0; } map $http_cookie $cache_uid { default nil; # hommage to Lisp :) ~SESS[[:alnum:]]+=(?[[:graph:]]+) $session_id;
}
+----------------------------------------------------------------------+
conf.d/fastcgi_microcache_zone.conf +----------------------------------------------------------------------+ fastcgi_cache_path /var/cache/nginx/microcache levels=1:2 keys_zone=microcache:5M max_size=1G inactive=2h loader_threshold=2000000 loader_sleep=1 loader_files=100000; +----------------------------------------------------------------------+
conf.d/php_fpm_status_vhost.conf +----------------------------------------------------------------------+ location = /phpfpm-status { if ($dont_show_fpm_status) { return 404; } include snippets/fastcgi-php.conf; include snippets/fastcgi_pass.conf; access_log off; }
location = /phpfpm-ping { if ($dont_show_fpm_status) { return 404; } include snippets/fastcgi-php.conf; include snippets/fastcgi_pass.conf; access_log off; } +----------------------------------------------------------------------+
snippets/fastcgi-php.conf +----------------------------------------------------------------------+ fastcgi_split_path_info ^(.+.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php; +----------------------------------------------------------------------+
snippets/fastcgi_pass.conf +----------------------------------------------------------------------+
fastcgi_pass unix:/var/run/php-fpm/www.php5-fpm.sock;
fastcgi_pass phpcgi;
fastcgi_pass www;
+----------------------------------------------------------------------+
Checking the configuration file results in a "Syntax Ok" message, nginx can get launched and html files are served like a charm, even the nginx status page can be pulled.
Looking into the error/debug file reveals +----------------------------------------------------------------------+ 2015/08/26 11:13:39 [debug] 32689#32689: _2 http header: "Host: my.host.local" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "Cache-Control: max-age=0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "Cookie: ck_login_id_20=1; ck_login_language_20=en_us; _pk_id.1.9807=7f9462efb2565826.1440510573.1.1440577057.1440510573.; _pkses.1.9807=; PHPSESSID=6frcrj852ns5hmtpum3me8o6m1; PIWIK_SESSID=c6olsns21t9pgngalch0jak950; TRACKID=feb76f8fcaa01cb61cc137ec587c96b1" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "Connection: keep-alive" 2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "Accept-Language: en-us" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "Accept-Encoding: gzip, deflate" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header: "DNT: 1" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http header done 2015/08/26 11:13:39 [debug] 32689#32689: 2 event timer del: 18: 1766434846 2015/08/26 11:13:39 [debug] 32689#32689: 2 generic phase: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 rewrite phase: 1 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var 2015/08/26 11:13:39 [debug] 32689#32689: 2 http map started 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http map: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43" "0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if: false 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var 2015/08/26 11:13:39 [debug] 32689#32689: 2 http geo started: 192.168.5.100 2015/08/26 11:13:39 [debug] 32689#32689: 2 http geo: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if: false 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var 2015/08/26 11:13:39 [debug] 32689#32689: 2 http map started 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "GET" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http map: "GET" "0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if: false 2015/08/26 11:13:39 [debug] 32689#32689: 2 test location: "/phpmyadm" 2015/08/26 11:13:39 [debug] 32689#32689: 2 test location: "/phpfpm-ping" 2015/08/26 11:13:39 [debug] 32689#32689: 2 test location: "/phpinfo" 2015/08/26 11:13:39 [debug] 32689#32689: 2 test location: "/phpfpm-status" 2015/08/26 11:13:39 [debug] 32689#32689: 2 using configuration "=/phpfpm-status" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http cl:-1 max:10485760 2015/08/26 11:13:39 [debug] 32689#32689: 2 rewrite phase: 3 2015/08/26 11:13:39 [debug] 32689#32689: 2 rewrite phase: 4 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var 2015/08/26 11:13:39 [debug] 32689#32689: 2 http geo started: 192.168.5.100 2015/08/26 11:13:39 [debug] 32689#32689: 2 http geo: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "0" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script if: false 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script complex value 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script set $path_info 2015/08/26 11:13:39 [debug] 32689#32689: 2 post rewrite phase: 5 2015/08/26 11:13:39 [debug] 32689#32689: 2 generic phase: 6 2015/08/26 11:13:39 [debug] 32689#32689: 2 generic phase: 7 2015/08/26 11:13:39 [debug] 32689#32689: 2 generic phase: 8 2015/08/26 11:13:39 [debug] 32689#32689: 2 generic phase: 9 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "¿®d" 2015/08/26 11:13:39 [debug] 32689#32689: 2 limit conn: B7CA6CC6 1 2015/08/26 11:13:39 [debug] 32689#32689: 2 add cleanup: 012E4E20 2015/08/26 11:13:39 [debug] 32689#32689: 2 access phase: 10 2015/08/26 11:13:39 [debug] 32689#32689: 2 access phase: 11 2015/08/26 11:13:39 [debug] 32689#32689: 2 access phase: 12 2015/08/26 11:13:39 [debug] 32689#32689: 2 post access phase: 13 2015/08/26 11:13:39 [debug] 32689#32689: 2 try files phase: 14 2015/08/26 11:13:39 [debug] 32689#32689: 2 http script var: "/phpfpm-status" 2015/08/26 11:13:39 [debug] 32689#32689: 2 trying to use file: "/phpfpm-status" "/data/www/sites/my.host.local/htdocs/phpfpm-status" 2015/08/26 11:13:39 [debug] 32689#32689: 2 trying to use file: "=404" "/data/www/sites/my.host.local/htdocs=404" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http finalize request: 404, "/phpfpm-status?" a:1, c:1 2015/08/26 11:13:39 [debug] 32689#32689: 2 http special response: 404, "/phpfpm-status?" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http set discard body 2015/08/26 11:13:39 [debug] 32689#32689: 2 uploadprogress error-tracker error: 404 2015/08/26 11:13:39 [debug] 32689#32689: 2 uploadprogress error-tracker not tracking in this location 2015/08/26 11:13:39 [debug] 32689#32689: 2 xslt filter header 2015/08/26 11:13:39 [debug] 32689#32689: *2 HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 26 Aug 2015 09:13:39 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=10
Vary: Accept-Encoding
Content-Encoding: gzip
2015/08/26 11:13:39 [debug] 32689#32689: 2 write new buf t:1 f:0 012E4F70, pos 012E4F70, size: 226 file: 0, size: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 http write filter: l:0 f:0 s:226 2015/08/26 11:13:39 [debug] 32689#32689: 2 http output filter "/phpfpm-status?" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http copy filter: "/phpfpm-status?" 2015/08/26 11:13:39 [debug] 32689#32689: 2 image filter 2015/08/26 11:13:39 [debug] 32689#32689: 2 xslt filter body 2015/08/26 11:13:39 [debug] 32689#32689: 2 http postpone filter "/phpfpm-status?" 012E5140 2015/08/26 11:13:39 [debug] 32689#32689: 2 http gzip filter 2015/08/26 11:13:39 [debug] 32689#32689: 2 malloc: 0127D7D0:12288 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip alloc: n:1 s:5828 a:8192 p:0127D7D0 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip alloc: n:512 s:2 a:1024 p:0127F7D0 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip alloc: n:512 s:2 a:1024 p:0127FBD0 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip alloc: n:512 s:2 a:1024 p:0127FFD0 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip alloc: n:256 s:4 a:1024 p:012803D0 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip in: 012E5170 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip in_buf:012E5070 ni:0014AE1C ai:116 2015/08/26 11:13:39 [debug] 32689#32689: 2 malloc: 012807D8:8192 2015/08/26 11:13:39 [debug] 32689#32689: 2 deflate in: ni:0014AE1C no:012807D8 ai:116 ao:8192 fl:0 redo:0 2015/08/26 11:13:39 [debug] 32689#32689: 2 deflate out: ni:0014AE90 no:012807D8 ai:0 ao:8192 rc:0 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip in_buf:012E5070 pos:0014AE1C 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip in: 012E5180 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip in_buf:012E50B0 ni:0014A028 ai:46 2015/08/26 11:13:39 [debug] 32689#32689: 2 deflate in: ni:0014A028 no:012807D8 ai:46 ao:8192 fl:4 redo:0 2015/08/26 11:13:39 [debug] 32689#32689: 2 deflate out: ni:0014A056 no:01280843 ai:0 ao:8085 rc:1 2015/08/26 11:13:39 [debug] 32689#32689: 2 gzip in_buf:012E50B0 pos:0014A028 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 0127D7D0 2015/08/26 11:13:39 [debug] 32689#32689: 2 posix_memalign: 0127D7D0:4096 @16 2015/08/26 11:13:39 [debug] 32689#32689: 2 http chunk: 10 2015/08/26 11:13:39 [debug] 32689#32689: 2 http chunk: 115 2015/08/26 11:13:39 [debug] 32689#32689: 2 write old buf t:1 f:0 012E4F70, pos 012E4F70, size: 226 file: 0, size: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 write new buf t:1 f:0 0127D860, pos 0127D860, size: 4 file: 0, size: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 write new buf t:0 f:0 00000000, pos 0014CB30, size: 10 file: 0, size: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 write new buf t:1 f:0 012807D8, pos 012807D8, size: 115 file: 0, size: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 write new buf t:0 f:0 00000000, pos 00124A88, size: 7 file: 0, size: 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 http write filter: l:1 f:1 s:362 2015/08/26 11:13:39 [debug] 32689#32689: 2 http write filter limit 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 writev: 362 of 362 2015/08/26 11:13:39 [debug] 32689#32689: 2 http write filter 00000000 2015/08/26 11:13:39 [debug] 32689#32689: 2 http copy filter: 0 "/phpfpm-status?" 2015/08/26 11:13:39 [debug] 32689#32689: 2 http finalize request: 0, "/phpfpm-status?" a:1, c:1 2015/08/26 11:13:39 [debug] 32689#32689: 2 set http keepalive handler 2015/08/26 11:13:39 [debug] 32689#32689: 2 http close request 2015/08/26 11:13:39 [debug] 32689#32689: 2 http log handler 2015/08/26 11:13:39 [debug] 32689#32689: 2 run cleanup: 012E4E20 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 012807D8 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 00000000 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 012E4230, unused: 8 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 0127D7D0, unused: 3784 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 0136A3B0 2015/08/26 11:13:39 [debug] 32689#32689: 2 hc free: 00000000 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 hc busy: 00000000 0 2015/08/26 11:13:39 [debug] 32689#32689: 2 tcp_nodelay 2015/08/26 11:13:39 [debug] 32689#32689: 2 reusable connection: 1 2015/08/26 11:13:39 [debug] 32689#32689: 2 event timer add: 18: 10000:1766384847 2015/08/26 11:13:39 [debug] 32689#32689: 2 post event 0137ECE8 2015/08/26 11:13:39 [debug] 32689#32689: 2 delete posted event 0137ECE8 2015/08/26 11:13:39 [debug] 32689#32689: 2 http keepalive handler 2015/08/26 11:13:39 [debug] 32689#32689: 2 malloc: 0136A3B0:1024 2015/08/26 11:13:39 [debug] 32689#32689: 2 recv: fd:18 -1 of 1024 2015/08/26 11:13:39 [debug] 32689#32689: 2 recv() not ready (11: Resource temporarily unavailable) 2015/08/26 11:13:39 [debug] 32689#32689: 2 free: 0136A3B0 2015/08/26 11:13:49 [debug] 32689#32689: 2 event timer del: 18: 1766384847 2015/08/26 11:13:49 [debug] 32689#32689: 2 http keepalive handler 2015/08/26 11:13:49 [debug] 32689#32689: 2 close http connection: 18 2015/08/26 11:13:49 [debug] 32689#32689: 2 reusable connection: 0 2015/08/26 11:13:49 [debug] 32689#32689: 2 free: 00000000 2015/08/26 11:13:49 [debug] 32689#32689: 2 free: 01278F30, unused: 8 2015/08/26 11:13:49 [debug] 32689#32689: 2 free: 01279050, unused: 232 +----------------------------------------------------------------------+
Any hints as how to tackle this one would be highly appreciated! :)
Another issue would be eh. my.host.local's document root is set to '/data/www/sites/my.host.local/htdocs', d7 would be located at '/data/www/sites/my.host.local/apps/drupal' and should be accessible by 'http://my.host.local/drupal'.
And my.host2.local's document root is set to /data/www/sites/my.host2.local/apps/drupal' and should be accessible by 'http://my.host2.local'.
The latter I reckon should be possible right out of the box using your configuration, but how about the former one?
--Sil68