Discussion:
[newbie] Two configuration issues with PHP5-FPM
Gilles Ganault
2010-07-15 11:03:59 UTC
Permalink
Hello,

Things are a bit more clear this morning, but I'm still unable to
serve PHP5 scripts through Nginx + PHP5-FPM (works OK with "php-cgi
-b") on Ubuntu 10.04.

Using the "default" file mentioned here...

www.howtoforge.com/installing-nginx-with-php-5.3-and-php-fpm-on-ubuntu-lucid-lynx-10.04-without-compiling-anything

... and the usual index.php (owned by www-data.www-data) to run "<?php
phpinfo(); ?>", I get two errors:

1. http://192.168.0.8/ -> "403 Forbidden":

"directory index of "/var/www/" is forbidden, client: 192.168.0.1,
server: localhost, request: "GET / HTTP/1.1", host: "192.168.0.8""

So, I tried being specific:

2. http://192.168.0.8/index.php: Empty screen.

Only this in error.log:

2010/07/15 12:50:36 [error] 1146#0: *21 open() "/var/www/favicon.ico"
failed (2: No such file or directory), client: 192.168.0.1, server:
localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.8"

I get this in /var/log/nginx/localhost.access.log :

192.168.0.1 - - [15/Jul/2010:12:52:15 +0200] "GET /index.php HTTP/1.1"
404 31 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/532.9 (KHTML, like Gecko) Iron/4.0.280.0 Chrome/4.0.280.0
Safari/532.9"

(notice error 404)

To check if it could be due to the fact that I use the server's IP
address (192.168.0.8) instead of "localhost" to connect to it from a
Windows host, I tried this:

1. vi /etc/nginx/sites-available/default:
server {
listen 80;
#ME server_name localhost;
server_name 192.168.0.8;
2. /etc/init.d/nginx restart

http://192.168.0.8/index.php = Still empty page :-/

Any idea what's wrong with my config?

Thank you for any hint.
Gilles Ganault
2010-07-15 11:17:51 UTC
Permalink
On Thu, 15 Jul 2010 13:03:59 +0200, Gilles Ganault
Post by Gilles Ganault
Things are a bit more clear this morning, but I'm still unable to
serve PHP5 scripts through Nginx + PHP5-FPM (works OK with "php-cgi
-b") on Ubuntu 10.04.
I left files installed by apt-get under /etc/php5/ untouched. Do I
need to customize them maybe so that PHP5-FPM works OK with Nginx?

# ll /etc/php5/
cgi/
cli/
conf.d/
fpm/

# ll /etc/php5/fpm/
conf.d -> ../conf.d/
php5-fpm.conf
php.ini

Thank you.
Gilles Ganault
2010-07-15 14:12:17 UTC
Permalink
On Thu, 15 Jul 2010 13:17:51 +0200, Gilles Ganault
Post by Gilles Ganault
I left files installed by apt-get under /etc/php5/ untouched. Do I
need to customize them maybe so that PHP5-FPM works OK with Nginx?
Found it: The sample configuration file I used had the following,
wrong line:

fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
www.howtoforge.com/installing-nginx-with-php-5.3-and-php-fpm-on-ubuntu-lucid-lynx-10.04-without-compiling-anything

Changing this to: /var/www/nginx-default/$fastcgi_script_name and
restarting Nginx solved the issue.

But I wonder if this the right way to solve the problem :-/
Gilles Ganault
2010-07-15 16:37:45 UTC
Permalink
On Thu, 15 Jul 2010 16:12:17 +0200, Gilles Ganault
Post by Gilles Ganault
But I wonder if this the right way to solve the problem :-/
With some external help, I changed "default" to this, but still not
working :-/ It's either 404 or 403

http://pastebin.com/xC35HZDK

What do you guys use for SCRIPT_FILENAME?

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
brianmercer
2010-07-15 18:01:43 UTC
Permalink
Gilles Ganault Wrote:
-------------------------------------------------------
Post by Gilles Ganault
On Thu, 15 Jul 2010 16:12:17 +0200, Gilles Ganault
Post by Gilles Ganault
But I wonder if this the right way to solve the
problem :-/
With some external help, I changed "default" to
this, but still not
working :-/ It's either 404 or 403
http://pastebin.com/xC35HZDK
What do you guys use for SCRIPT_FILENAME?
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
_______________________________________________
nginx mailing list
http://nginx.org/mailman/listinfo/nginx
Try changing

listen 80;

to

listen 80 default;

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,109131,109259#msg-109259
Gilles Ganault
2010-07-16 00:13:02 UTC
Permalink
On Thu, 15 Jul 2010 14:01:43 -0400, "brianmercer"
Post by brianmercer
Try changing
listen 80;
to
listen 80 default;
Thanks Brian, but it makes no difference.

At this point...

1. http://192.168.0.8/index.php does display phpinfo(); if I change
set "fastcgi_param SCRIPT_FILENAME
/var/www/nginx-default$fastcgi_script_name;"

2. http://192.168.0.8/ = 403.
[error] 1574#0: *3 directory index of "/var/www/" is forbidden,
client: 192.168.0.1, server: localhost, request: "GET / HTTP/1.1",
host: "192.168.0.8"

I tried adding "autoindex on;" to the "server" part, and then to the "
location /" part, to no avail.

The three config files can be found here:
http://pastebin.com/LYvnMu7X

FWIW, I followed this document:
"Installing Nginx With PHP 5.3 And PHP-FPM On Ubuntu Lucid Lynx
(10.04) Without Compiling Anything"
www.howtoforge.com/installing-nginx-with-php-5.3-and-php-fpm-on-ubuntu-lucid-lynx-10.04-without-compiling-anything

Thank you.
Gilles Ganault
2010-07-16 00:19:48 UTC
Permalink
On Fri, 16 Jul 2010 02:13:02 +0200, Gilles Ganault
Post by Gilles Ganault
Thanks Brian, but it makes no difference.
I think I found it: The "root" must be set to this instead of
"/var/www":

============
server {
[...]
root /var/www/nginx-default;

[...]
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
============

Now, I can use either "http://192.168.0.8/" or
"http://192.168.0.8/index.php".

BTW, this is for a single-site server, so I have no use for VPS.

Hopefully, the way it's configured won't have unintended consequences
further down the road.

Thanks for the help.
Gilles Ganault
2010-07-16 01:08:07 UTC
Permalink
On Fri, 16 Jul 2010 02:19:48 +0200, Gilles Ganault
Post by Gilles Ganault
I think I found it: The "root" must be set to this instead of
Something strange, though: Calling index.php triggers _four_ lines in
/var/log/nginx/localhost.access.log:

===========
192.168.0.1 - - [16/Jul/2010:03:05:45 +0200] "GET /index.php HTTP/1.1"
200 10062 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
AppleWebKit/532.9 (KHTML, like Gecko) Iron/4.0.280.0 Chrome/4.0.280.0
Safari/532.9"

192.168.0.1 - - [16/Jul/2010:03:05:45 +0200] "GET
/index.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2536
"http://192.168.0.8/index.php" "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Iron/4.0.280.0
Chrome/4.0.280.0 Safari/532.9"

192.168.0.1 - - [16/Jul/2010:03:05:45 +0200] "GET
/index.php?=SUHO8567F54-D428-14d2-A769-00DA302A5F18 HTTP/1.1" 200 2825
"http://192.168.0.8/index.php" "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Iron/4.0.280.0
Chrome/4.0.280.0 Safari/532.9"

192.168.0.1 - - [16/Jul/2010:03:05:45 +0200] "GET
/index.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2158
"http://192.168.0.8/index.php" "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Iron/4.0.280.0
Chrome/4.0.280.0 Safari/532.9"
===========

Is there a reason why Nginx would send the document four times?

Loading...