PHP not executing with Nginx

So I followed the guide in the Linode Library for installing a LEMP server on Ubuntu 11.10, but when I type in the URL my browser tries to download the actual text file 'index.php'

I have a good feeling that 'index.php' just isn't being handled by FastCGI, so where should I look/check to see where everything went south?

6 Replies

You can find some good information about PHP & fastcgi here: http://www.fastcgi.com/drupal/node/5?q=node/10

Kind regards

Michael

== Full time system administrator for hire ==

Post the contents of your nginx configuration file that's serving the site. It's probably a misconfiguration.

Below is my nginx.conf, where I have replaced the domain with ampersands for anonymity (maybe I'm paranoid :P). I will post the virtual host configuration in the next post. Enjoy.

user nobody;

worker_processes 1;

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;

#logformat main '$remoteaddr - $remoteuser [$timelocal] "$request" '

# '$status $bodybytessent "$http_referer" '

# '"$httpuseragent" "$httpxforwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/sites-enabled/&&&&&&&&.org;

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

# listen 8000;

# listen somename:8080;

# server_name somename alias another.alias;

# location / {

# root html;

# index index.html index.htm;

# }

#}

# HTTPS server

#

#server {

# listen 443;

# server_name localhost;

# ssl on;

# ssl_certificate cert.pem;

# sslcertificatekey cert.key;

# sslsessiontimeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;

# ssl_ciphers HIGH:!aNULL:!MD5;

# sslpreferserver_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

}

Here is my virtual host configuration, again with the domain replaced by ampersands.

server {

listen 80 default_server;

   access_log /srv/www/&&&&&&&&.org/logs/access.log;

   error_log /srv/www/&&&&&&&&.org/logs/error.log;

   root /srv/www/&&&&&&&&.org/public_html;

server_name &&&&&&&&.org www.&&&&&&&&.org;

location / {

           index    index.htm index.html index.php;

}

location .php$ {

           try_files $uri =404;

include /etc/nginx/fastcgi_params;

fastcgi_index index.php;

fastcgi_pass 127.0.0.1:9000;

fastcgiparam SCRIPTFILENAME /srv/www/&&&&&&&&.org/publichtml$fastcgiscript_name;

}

}

location \.php$ { should be location ~ \.php$ { You missed the ~

Damnit haha this worked. Thank you very much.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct