Nginx + Php5-fpm not rendering php files
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:
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
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
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
9 Replies
1. Are you sure /var/www/eman is where your PHP files are located?
2. Try removing that last slash before $fastcgiscriptname. Technically this shouldn't matter, but just to be on the safe side…
I tried removing the slash, but no luck.
I also tried:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Anything else I could try?
Do you have any safemode or openbasedir 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?
Thanks a lot.
I've checked the fastcgiparams, nope, nothing there to override the SCRIPT_FILENAME
safemode is OFF, and openbasedir 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:
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;
}
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;
}
}
Copying the old fastcgi_params back and restarting nginx solved it.