Error "No input file specified" (wrong fastcgi_param?)

492 views
Skip to first unread message

Stefan Scott

unread,
Nov 30, 2008, 9:45:22 PM11/30/08
to highload-php-en
Hello Everyone -

I've installed nginx-0.6.33 + php-5.2.6 + php-fpm-0.5.9 + xcache-1.2.2
under Debian 4.0 (Etch) on a VPS (virtual private server), using the
instructions here:

http://wiki.codemongers.com/NginxFullExample
http://www.yawn.it/2008/04/30/nginx-php-php-fpm-on-debian-etch-40/
http://firedemon.su/?p=200 ( к счастью учил русский язык давно в
колледже :-)
http://www.darvilworld.com/?cat=5

I haven't installed Drupal or WordPress yet, because I just want to
test this basic setup first.

--------------------------------------------------------

Now my browser can display index.html with no problem:

$ cat /usr/local/nginx/html/myvhost1.com/index.html
>>> Welcome to myvhost1.com ...


But when I try to display index.php...

$ cat /usr/local/nginx/html/myvhost1.com/index.php
<? phpinfo(); ?>

...my browser displays the following error:

>>> No input file specified.

--------------------------------------------------------

As a further test, I deliberately entered some bad pages:

http://myvhost1.com/bad-page.html

>>> 404 Not Found
>>> nginx/0.6.33

http://myvhost1.com/bad-page.php

>>> No input file specified.

The file /usr/local/nginx/html/myvhost1.com/index.php exists and the
file /usr/local/nginx/html/myvhost1.com/index.php does not exist:

$ ls -l /usr/local/nginx/html/myvhost1.com
total 12
-rw-r--r-- 1 root staff 383 2008-11-27 15:13 50x.html
-rw-r--r-- 1 root staff 146 2008-11-27 15:17 index.html
-rw-r--r-- 1 root staff 17 2008-12-01 01:30 index.php

but for the file that does exist and for the file that does not exist,
the browser gives the message "No input file specified" in both cases.

--------------------------------------------------------

Here's my nginx.conf file:

$ cat /usr/local/nginx/conf/nginx.conf

user www-data www-data;
worker_processes 2;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include 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 logs/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

gzip on;
gzip_comp_level 1; gzip_proxied any;
gzip_types text/plain
text/html
text/css
application/x-javascript
text/xml
application/xml
application/xml+rss
text/javascript;

server {
listen 80;
server_name .myvhost1.com;

location / {
root html/myvhost1.com;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root html;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
}
}

}

--------------------------------------------------------

And here's my fastcgi_params file (I added the line at the end):

$ cat /usr/local/nginx/conf/fastcgi_params

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;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

# I ADDED THIS LINE
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

--------------------------------------------------------

I'm new to all this so I don't know what I'm doing wrong here.

I'd appreciate any ideas you might have.

Thanks.

- Stefan Scott

Andrei Nigmatulin

unread,
Nov 30, 2008, 10:04:22 PM11/30/08
to highloa...@googlegroups.com
On Monday 01 December 2008 05:45, Stefan Scott wrote:
> Hello Everyone -
>
> I've installed nginx-0.6.33 + php-5.2.6 + php-fpm-0.5.9 + xcache-1.2.2
> under Debian 4.0 (Etch) on a VPS (virtual private server), using the
> instructions here:
>
> http://wiki.codemongers.com/NginxFullExample
> http://www.yawn.it/2008/04/30/nginx-php-php-fpm-on-debian-etch-40/
> http://firedemon.su/?p=200 ( к счастью учил русский язык давно в
> колледже :-)
> http://www.darvilworld.com/?cat=5
>
> I haven't installed Drupal or WordPress yet, because I just want to
> test this basic setup first.
>
> --------------------------------------------------------
>
> Now my browser can display index.html with no problem:
>
> $ cat /usr/local/nginx/html/myvhost1.com/index.html
>
> >>> Welcome to myvhost1.com ...
>
> But when I try to display index.php...
>
> $ cat /usr/local/nginx/html/myvhost1.com/index.php
> <? phpinfo(); ?>
>
> ...my browser displays the following error:
> >>> No input file specified.

The problem with your configuration is that $document_root is set to
"/usr/local/nginx/html" for "location ~ \.php$" context.

You need either move "root html/myvhost1.com;" from "location /" context to
server or add "root html/myvhost1.com;" into "location ~ \.php$" context.

--
Andrei Nigmatulin
GPG PUB KEY 6449830D

Now I lay me down to sleep(3)
Pray the OS my core to keep
If I die before I wake
Pray the Disk my core to take

Stefan Scott

unread,
Nov 30, 2008, 9:59:09 PM11/30/08
to highload-php-en
Also, in case this helps, here is a portion of my /usr/local/etc/php-
fpm.conf file:

## /usr/local/etc/php-fpm.conf
## THE BELOW HAVE BEEN UPDATED AS SHOWN, FOLLOWING THE INSTRUCTIONS
AT:
## http://www.yawn.it/2008/04/30/nginx-php-php-fpm-on-debian-etch-40/
## http://firedemon.su/?p=200 ( к счастью учил русский язык давно в


## LINES 40-42
Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/
socket'
<value name="listen_address">127.0.0.1:9000</value>

## LINES 63-67
Unix user of processes
<value name="user">www-data</value>

Unix group of processes
<value name="group">www-data</value>

Stefan Scott

unread,
Nov 30, 2008, 10:16:21 PM11/30/08
to highload-php-en
Thanks Andrei for your fast reply. It worked!

It feels very exciting to have a fast webserver now running nginx +
php-fpm + xcache. Next I will install Drupal and Rails and WordPress!

I had previously failed to understand that '$document_root' in file /
usr/local/nginx/conf/fastcgi_params is the same thing as 'root' in the
location context in file /usr/local/nginx/conf/nginx.conf - but of
course now that seems very clear.

- Stefan Scott

On Dec 1, 1:04 am, Andrei Nigmatulin <andrei.nigmatu...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages