Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have nginx installed on my VPS which is running CentOS 6.3 and I can't seem to get any PHP files to work.

Here is my nginx.conf file:-

    user  nginx;
    worker_processes  2;

    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;


    events {
worker_connections  1024;
    }


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

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    server_names_hash_bucket_size 128;
    server {
    server_name example.org www.example.org;
    listen 198.245.51.xxx;
    root /var/www/forum;
    index index.html index.htm index.php;
    access_log /var/log/virtualmin/example.org_access_log;
    error_log /var/log/virtualmin/example.org_error_log;
    include fastcgi_params;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    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_FILENAME /var/www/forum/$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /var/www/forum;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    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;
    fastcgi_param HTTPS $https;
    location ~ \.php$ {
        fastcgi_pass           127.0.0.1:9000;
        fastcgi_index          index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/forum/$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT /var/www/forum;
        include                 /etc/nginx/fastcgi_params;

    }
    ssl_certificate /home/example/ssl.cert;
    ssl_certificate_key /home/example/ssl.key;
    fastcgi_read_timeout 60;
            autoindex on;
    }
    }

I get the following message whenever I try to open www.mydomain.com/index.php or any other php file:-

http://i.imgur.com/eoy0ijT.png

Thanks in advance! Please let me know if I can post anything else.

share|improve this question
    
What's in /var/log/nginx/error.log & /var/log/virtualmin/example.org_error_log? –  imel96 May 12 '13 at 23:16
    
You have "fastcgi_param SCRIPT_FILENAME" set twice - once in the server block and once in the location block. This is usually set in the fastcgi_params file - which you also have included. –  Danack May 13 '13 at 1:54
    
Wait - you also have both "include fastcgi_params;" and "include /etc/nginx/fastcgi_params;" ? –  Danack May 13 '13 at 1:56
    
And yeah - you should look in the error logs. Nginx should be returning a 502 error if the config was wrong. I am not sure what would output "File not found." It sounds like it may not be hitting nginx at all. –  Danack May 13 '13 at 1:59
add comment

1 Answer

up vote 1 down vote accepted

Changed user and group in domain.conf file and it started working again. It was set to User: Apache and Group: Apache by default.

Hope this helps someone with the same problem in the future! And thank you all for answering :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.