Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Dec 16, 2010 4:04 pm 
Offline
Junior Member

Joined: Thu Dec 16, 2010 4:02 pm
Posts: 21
Website: http://www.onlythebible.com
Hi all,

I've spent hours figuring out how to install Nginx + Ruby Enterprise Edition + PHP5-fpm and MYSQL, finally it is all installed and all seems to have started fine.

But for some reason php files are not being processed.

.html files work fine, but when I try and view a .php file it appears as though it doesn't exist, even though it does. Interestingly, when I try and view a .html file that doesn't exist I get a nice Nginx 404 message, but when I view a .php file it doesn't even give me that.

So to my novice understanding, it looks like there's either something wrong with the config, or Nginx and PHP-fpm aren't talking to each other.

I've been looking at as many other examples of nginx config files and I'm sure that side of things is okay. Well... here's the relevant bit of the conf file anyway:

Code:
location ~ \.php$ {
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME /var/www/eman/$fastcgi_script_name;
   include fastcgi_params;
 }


And

Code:
    fastcgi_connect_timeout 60;
 fastcgi_send_timeout 180;
 fastcgi_read_timeout 180;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 4 256k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 fastcgi_intercept_errors on;


Any help is greatly appreciated.

Here are the headers being returned from the test php file "http://eman.id.au/test.php":

Code:
HTTP/1.1 404 Not Found =>
Server => nginx/0.8.54
Date => Thu, 16 Dec 2010 19:30:30 GMT
Content-Type => text/html
Connection => close
X-Powered-By => PHP/5.3.2-1ubuntu4.5ppa5~lucid1


Top
   
 Post subject:
PostPosted: Thu Dec 16, 2010 6:36 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
The X-Powered-By header indicates that nginx is talking to PHP all right. The 404 error looks different from the nginx standard 404 message because it's generated by PHP, not nginx. I get the same symptoms when I try to call a non-existent PHP script.

1. Are you sure /var/www/eman is where your PHP files are located?
2. Try removing that last slash before $fastcgi_script_name. Technically this shouldn't matter, but just to be on the safe side...


Top
   
 Post subject: Config Change
PostPosted: Fri Dec 17, 2010 12:55 am 
Offline
Junior Member

Joined: Thu Dec 16, 2010 4:02 pm
Posts: 21
Website: http://www.onlythebible.com
Yes, the full path to the php file is: /var/www/eman/test.php

I tried removing the slash, but no luck.

I also tried:

Code:
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;


Anything else I could try?


Top
   
 Post subject:
PostPosted: Fri Dec 17, 2010 1:19 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Do you have anything in /etc/nginx/fastcgi_params or any other nginx config file that might override your SCRIPT_FILENAME variable? Can you post all of your nginx config files here? (If it's too big, use pastebin and post a link here.)

Do you have any safe_mode or open_basedir restrictions that might prevent PHP from opening the file? (Check /etc/php5/fpm/php.ini) Are you running PHP inside a chroot by any means?


Top
   
 Post subject:
PostPosted: Sat Dec 18, 2010 8:26 am 
Offline
Junior Member

Joined: Thu Dec 16, 2010 4:02 pm
Posts: 21
Website: http://www.onlythebible.com
Sorry, but right now I'm leaving for Christmas Holidays... But I'll check all that as soon as I've got time, and post back with what I find.

Thanks a lot.[/code]


Top
   
 Post subject:
PostPosted: Thu Dec 23, 2010 9:02 pm 
Offline
Junior Member

Joined: Thu Dec 16, 2010 4:02 pm
Posts: 21
Website: http://www.onlythebible.com
Okay,

I've checked the fast_cgi_params, nope, nothing there to override the SCRIPT_FILENAME

safe_mode is OFF, and open_basedir is set to nothing
I'm not clear what chroot is, but I don't think I'm using it.

nginx.conf is as follows:

Code:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
   worker_connections 1024;
   # multi_accept on;
}

http {

   sendfile on;
   tcp_nopush on;
   tcp_nodelay on;
   keepalive_timeout 65;
   types_hash_max_size 2048;

   include /etc/nginx/mime.types;
   default_type application/octet-stream;

   access_log /var/log/nginx/access.log;
   error_log /var/log/nginx/error.log;

   gzip on;
   gzip_disable "msie6";

    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

   include /etc/nginx/conf.d/*.conf;
   include /etc/nginx/sites-enabled/*;
   
   fastcgi_connect_timeout 60;
   fastcgi_send_timeout 180;
   fastcgi_read_timeout 180;
   fastcgi_buffer_size 128k;
   fastcgi_buffers 4 256k;
   fastcgi_busy_buffers_size 256k;
   fastcgi_temp_file_write_size 256k;
   fastcgi_intercept_errors on;

}


Last edited by Emmanuel2 on Thu Dec 23, 2010 9:06 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Thu Dec 23, 2010 9:03 pm 
Offline
Junior Member

Joined: Thu Dec 16, 2010 4:02 pm
Posts: 21
Website: http://www.onlythebible.com
The other nginx conf file, for the eman.id.au domain is:

Code:
server {
 listen 80;
 server_name *.eman.id.au;
}
 
server {
 listen 80;
 server_name eman.id.au;
 location / {
 root   /var/www/eman;
 index  index.php index.html index.htm;
 }
 
 location ~ \.php$ {
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include fastcgi_params;
 }

}


Top
   
 Post subject:
PostPosted: Wed Jan 19, 2011 4:32 pm 
Offline
Senior Member

Joined: Wed Jun 16, 2010 8:22 pm
Posts: 61
Website: http://www.kevinmccaughey.org
Did you ever find the answer? I would be grateful if you could let us know as I am also having nginx problems and reading through your config I can't see anything wrong with it - it's almost identical to mine (which doesn't work either for anything other than index files.


Top
   
 Post subject:
PostPosted: Fri Apr 29, 2011 6:57 am 
Offline

Joined: Fri Apr 29, 2011 6:55 am
Posts: 1
I had a similar problem when upgrading Ubuntu from 10.10 to 11.04. I saw that file /etc/nginx/fastcgi_params was empty after I upgraded.

Copying the old fastcgi_params back and restarting nginx solved it.


Top
   
 Post subject:
PostPosted: Fri Apr 29, 2011 8:03 am 
Offline
Senior Newbie

Joined: Fri Apr 09, 2010 1:53 pm
Posts: 17
You could also use fastcgi.conf which even solves the $document_root problem.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group