If anyone has played with nginx + php-fpm, they may have run into the
"No input file specified" problem. Google will show dozens of pages
explaining what the problem is and how to fix it. Been there, spent
last weekend doing it.
After too much frustration, I tried the exact same nginx config with
php-fastcgi-5.3, and it worked like a charm. Maybe one day I'll go back
to figure out what I was doing wrong with php-fpm, but for now, the
'regular' fastcgi will do.
Until it silently died. To keep this story short, I'll leave it at:
yes, it likes to silently die on its own once or twice a day for no
apparent reason. I figured I'd go back to trying php-fpm.
I'll post copies of my nginx.conf, fastcgi_params, php-fpm.conf and
dmesg below, but the more interesting part is the kdump I got from
ktrace'ing php-fpm. The server is OpenBSD 5.1/i386 built from sources
obtained a few days before the shift to 5.1-current.
I'll post the full output below, but here's the relevant couple of bits
to my simple eyes. Here's where it gets the fastcgi params, and they
look sane to me:
23595 php-fpm-5.3 GIO fd 5 read 888 bytes
"\f\0QUERY_STRING\^N\^CREQUEST_METHODGET\f\0CONTENT_TYPE\^N\0CONTENT_LENGTH\v\^RSCRIPT_NAME/who_is_online.php\v\
\^RREQUEST_URI/who_is_online.php\f\^RDOCUMENT_URI/who_is_online.php\r\^ODOCUMENT_ROOT/var/nginx/html\^O\bSERVE\
R_PROTOCOLHTTP/1.1\^Q\aGATEWAY_INTERFACECGI/1.1\^O\fSERVER_SOFTWAREnginx/1.0.11\v\vREMOTE_ADDR192.168.1.5\v\^E\
REMOTE_PORT39331\v\vSERVER_ADDR172.16.1.10\v\^CSERVER_PORT443\v\^QSERVER_NAMEwww.blackstaff.ca\^O\^CREDIRECT_S\
TATUS200\^O!SCRIPT_FILENAME/var/nginx/html/who_is_online.php
\^QHTTP_HOSTwww.blackstaff.ca\^OGHTTP_USER_AGE\
NTMozilla/5.0 (X11; OpenBSD amd64; rv:9.0.1) Gecko/20100101
Firefox/9.0.1\v?HTTP_ACCEPTtext/html,application/x\
html+xml,application/xml;q=0.9,*/*;q=0.8\^T\^NHTTP_ACCEPT_LANGUAGEen-us,en;q=0.5\^T\rHTTP_ACCEPT_ENCODINGgzip,\
deflate\^S\^^HTTP_ACCEPT_CHARSETISO-8859-1,utf-8;q=0.7,*;q=0.7\b\^AHTTP_DNT1\^O
HTTP_CONNECTIONkeep-alive\f*HTTP_REFERERhttps://www.blackstaff.ca/admin_reauth.php\^R
HTTP_CACHE_CONTROLmax-\
age=0\0\0"
And here's where it can't find the file:
23595 php-fpm-5.3 GIO fd 2 wrote 100 bytes
"ERROR: Unable to open primary script:
/var/nginx/html/who_is_online.php (No such file or directory)
"
23595 php-fpm-5.3 RET write 100/0x64
(it doesn't matter whether the file is who_is_online.php, index.php or
any other file.)
Really, the file exists, and the directory/file permissions are fine.
It worked just a moment before with php-fastcgi, just not with php-fpm.
Normally, they look like this:
# ls -l /var/nginx/html/who_is_online.php
-rw-r- 1 scott _nginx 149 Feb 27 18:44
/var/nginx/html/who_is_online.php
The php-fpm process was running as _nginx, which I confirmed with ps -aux.
Just on the off chance it _is_ file perms, I set everything from
/var/nginx to who_is_online.php owned _nginx:_nginx and chmod 777.
Anyone could read or even modify the file.
Still no dice, and I tried the same with index.php, and on my dev site
at /var/nginx.dev, all with the same results.
This problem is a real mystery to me, and I'm hoping I didn't miss
something crazy-simple. Can anyone explain it?
nginx was built from ports:
nginx version: nginx/1.0.11
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx
--conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx
--pid-path=/var/run/nginx.pid --lock-path=/var/nginx/tmp/nginx.lock
--http-client-body-temp-path=/var/nginx/tmp/client_body_temp
--http-proxy-temp-path=/var/nginx/tmp/proxy_temp
--http-fastcgi-temp-path=/var/nginx/tmp/fastcgi_temp
--http-scgi-temp-path=/var/nginx/tmp/scgi_temp
--http-uwsgi-temp-path=/var/nginx/tmp/uwsgi_temp
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log --user=_nginx --group=_nginx
--with-http_gzip_static_module --with-http_ssl_module
--with-http_stub_status_module --with-http_mp4_module --with-mail
--with-mail_ssl_module --with-ipv6
php is 5.3.10:
# pkg_info -q |grep php
php-5.3.10
php-bz2-5.3.10
php-curl-5.3.10
php-fastcgi-5.3.10
php-fpm-5.3.10
php-gmp-5.3.10
php-mcrypt-5.3.10
php-pgsql-5.3.10
Here's the kdump of a ktrace -d from watching one of the worker
processes. It was idle until I refreshed the browser page, and this is
what it said:
23595 php-fpm-5.3 RET poll 1
23595 php-fpm-5.3 CALL gettimeofday(715710552,0)
23595 php-fpm-5.3 RET gettimeofday 0
23595 php-fpm-5.3 CALL accept(0,-809783136,-809783140)
23595 php-fpm-5.3 STRU struct sockaddr { AF_INET, 127.0.0.1:28040 }
23595 php-fpm-5.3 RET accept 5
23595 php-fpm-5.3 CALL fcntl(5,F_GETFL,0)
23595 php-fpm-5.3 RET fcntl 6
23595 php-fpm-5.3 CALL gettimeofday(-809783288,0)
23595 php-fpm-5.3 RET gettimeofday 0
23595 php-fpm-5.3 CALL gettimeofday(-809783368,0)
235