Difference between revisions of "User:Woozle/nginx"
(scgi_params) |
(→Notes: 6/23) |
||
Line 12: | Line 12: | ||
===2012-06-21=== | ===2012-06-21=== | ||
Looks like the package "spawn-fcgi" may be the part of FastCGI that I need to install, extrapolating from [http://web.archive.org/web/20100208231201/http://www.johnyerhot.com/2008/02/12/how-to-nginx-fcgi-php-mysql-ruby-on-rails-rewrite-vhosts/ this]. Installing it... | Looks like the package "spawn-fcgi" may be the part of FastCGI that I need to install, extrapolating from [http://web.archive.org/web/20100208231201/http://www.johnyerhot.com/2008/02/12/how-to-nginx-fcgi-php-mysql-ruby-on-rails-rewrite-vhosts/ this]. Installing it... | ||
+ | ===2012-06-23=== | ||
+ | Noticed that [http://wiki.nginx.org/FcgiExample this] says "Unlike Apache or Lighttpd, Nginx does not automatically spawn FCGI processes. You must start them separately. ... So we simply run php -b 127.0.0.1:9000 manually, or create an init script like so...". | ||
+ | |||
+ | This turns out to be not quite correct; "php" by itself doesn't accept the -b parameter. You have to run php-cgi: | ||
+ | php-cgi -b 127.0.0.1:9000 | ||
+ | |||
+ | Unfortunately, I get this: | ||
+ | Cannot bind/listen socket - [98] Address already in use. | ||
+ | Couldn't create FastCGI listen socket on port 127.0.0.1:9000 | ||
+ | |||
+ | ...meaning that something is already listening there. Presumably that's [[PHP-FPM]]: | ||
+ | ps aux | grep php | ||
+ | woozle 11404 0.0 0.1 3372 752 pts/1 S+ 15:25 0:00 grep --color=auto php | ||
+ | root 24667 0.0 0.2 62892 1488 ? Ss Jun18 0:22 php-fpm: master process (/etc/php5/fpm/php-fpm.conf) | ||
+ | www-data 24668 0.0 0.3 63180 1984 ? S Jun18 0:00 php-fpm: pool www | ||
+ | www-data 24669 0.0 0.3 63180 1996 ? S Jun18 0:00 php-fpm: pool www | ||
+ | www-data 24670 0.0 0.3 63180 1996 ? S Jun18 0:00 php-fpm: pool www | ||
+ | www-data 24671 0.0 0.3 63180 1996 ? S Jun18 0:00 php-fpm: pool www | ||
+ | |||
+ | So, how can we determine if PHP-FPM is receiving the page request? | ||
+ | |||
==Background== | ==Background== | ||
* '''Distro''': Ubuntu 10.04.4 LTS | * '''Distro''': Ubuntu 10.04.4 LTS |
Revision as of 15:15, 23 June 2012
The Problem
nginx works with static files (and Ruby), but will not execute PHP files. PHP runs fine from a command line.
On requesting a PHP file (such as http://wiki.makeyourlaws.org/phpinfo.php), here's what seems to be happening:
- nginx receives the request
- nginx forwards it to PHP-FPM
- This can be done one of two ways -- either via a UNIX pipe or via a port. I've tried both; currently using port, I think.
- PHP never receives the request; the log file does not show it.
- nginx somehow receives a success code, and logs the request as successful (http code 200) returning a result of zero bytes.
- The web browser displays a blank page.
Notes
2012-06-21
Looks like the package "spawn-fcgi" may be the part of FastCGI that I need to install, extrapolating from this. Installing it...
2012-06-23
Noticed that this says "Unlike Apache or Lighttpd, Nginx does not automatically spawn FCGI processes. You must start them separately. ... So we simply run php -b 127.0.0.1:9000 manually, or create an init script like so...".
This turns out to be not quite correct; "php" by itself doesn't accept the -b parameter. You have to run php-cgi:
php-cgi -b 127.0.0.1:9000
Unfortunately, I get this:
Cannot bind/listen socket - [98] Address already in use. Couldn't create FastCGI listen socket on port 127.0.0.1:9000
...meaning that something is already listening there. Presumably that's PHP-FPM:
ps aux | grep php woozle 11404 0.0 0.1 3372 752 pts/1 S+ 15:25 0:00 grep --color=auto php root 24667 0.0 0.2 62892 1488 ? Ss Jun18 0:22 php-fpm: master process (/etc/php5/fpm/php-fpm.conf) www-data 24668 0.0 0.3 63180 1984 ? S Jun18 0:00 php-fpm: pool www www-data 24669 0.0 0.3 63180 1996 ? S Jun18 0:00 php-fpm: pool www www-data 24670 0.0 0.3 63180 1996 ? S Jun18 0:00 php-fpm: pool www www-data 24671 0.0 0.3 63180 1996 ? S Jun18 0:00 php-fpm: pool www
So, how can we determine if PHP-FPM is receiving the page request?
Background
- Distro: Ubuntu 10.04.4 LTS
nginx was compiled from source; PHP5 was installed from standard Ubuntu packages.
File Locations
- /opt/nginx/ - configuration and logging folders
- /opt/nginx/conf/nginx.conf - master config file
- /opt/nginx/conf/fastcgi.conf - FastCGI config file
- /opt/nginx/conf/scgi_params - Simple CGI config -- presumably not in use
- /etc/php5/fpm/ - PHP-FPM configuration
- /etc/php5/fpm/pool.d/www.conf - config file to actually edit
Folder Listings
- /opt/nginx
- total 25532
drwx------ 2 nobody root 4096 2012-04-26 18:47 client_body_temp drwxrwxr-x 2 root root 4096 2012-06-09 22:25 conf drwx------ 2 nobody root 4096 2011-12-02 23:20 fastcgi_temp drwxr-xr-x 2 root root 4096 2011-12-02 22:52 html drwxrwxr-x 2 root root 26071040 2012-06-11 06:43 logs drwx------ 2 nobody root 4096 2011-12-02 23:20 proxy_temp drwxrwxr-x 2 root root 4096 2012-04-22 04:41 sbin drwx------ 2 nobody root 4096 2011-12-02 23:20 scgi_temp drwx------ 2 nobody root 4096 2011-12-02 23:20 uwsgi_temp
- /opt/nginx/conf
- total 80
-rw-r--r-- 1 root root 979 2011-12-02 22:52 fastcgi.conf -rw-r--r-- 1 root root 979 2012-04-22 04:41 fastcgi.conf.default -rw-r--r-- 1 root root 909 2011-12-02 22:52 fastcgi_params -rw-r--r-- 1 root root 909 2012-04-22 04:41 fastcgi_params.default -rw-r--r-- 1 root root 2837 2012-04-22 04:41 koi-utf -rw-r--r-- 1 root root 2223 2012-04-22 04:41 koi-win -rw-r--r-- 1 root root 3362 2011-12-02 22:52 mime.types -rw-r--r-- 1 root root 3463 2012-04-22 04:41 mime.types.default -rw-r--r-- 1 root root 6651 2012-06-10 18:50 nginx.conf -rw-r--r-- 1 root root 2685 2012-04-22 04:41 nginx.conf.default -rw------- 1 root root 0 2012-04-23 16:29 nginx.conf.save -rw-r--r-- 1 root root 4208 2012-04-23 16:29 nginx.conf.save.1 -rw-r--r-- 1 root root 544 2011-12-02 22:52 scgi_params -rw-r--r-- 1 root root 544 2012-04-22 04:41 scgi_params.default -rw-r--r-- 1 root root 570 2011-12-02 22:52 uwsgi_params -rw-r--r-- 1 root root 570 2012-04-22 04:41 uwsgi_params.default -rw-r--r-- 1 root root 3610 2012-04-22 04:41 win-utf