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.

ok, again apparently a totally ridiculous problem which I just can't seem to figure out. nginx keeps serving my .php files as static files. I've installed nginx via the repositories on ubuntu. I've installed php5-fpm (no configuration changed there), both have been restarted. The setup I have is as far as I can tell identical to the setup on my laptop and it's running there. I've even set the file permissions exactly the same like the one on the laptop, but still to no avail.

so here's my sites-available/default file

server {
    #listen   80 default; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /home/johnny/*****; #replaced for privacy's sake
    index index.html index.htm;

    expires       0;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.html;
    }

    location /doc {
            root /usr/share;
            autoindex on;
            allow 127.0.0.1;
            deny all;
    }

    location /images {
            root /usr/share;
            autoindex off;
    }


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
    }

}

btw. nginx is serving static files just fine.

here's my netstat -lptu output, to prove that php5-fpm is indeed running

   $ sudo netstat -lptu
   Active Internet connections (only servers)
   Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
   tcp        0      0 localhost:ipp           *:*                     LISTEN      1246/cupsd
   tcp        0      0 *:17500                 *:*                     LISTEN      1788/dropbox
   tcp        0      0 localhost:9000          *:*                     LISTEN      10812/main.conf)
   tcp        0      0 localhost:mysql         *:*                     LISTEN      924/mysqld
   tcp        0      0 *:www                   *:*                     LISTEN      10362/nginx
   tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN      1246/cupsd
   udp        0      0 *:17500                 *:*                                 1788/dropbox
   udp        0      0 *:mdns                  *:*                                 802/avahi-daemon: r
   udp        0      0 *:36279                 *:*                                 802/avahi-daemon: r
   udp        0      0 *:bootpc                *:*                                 1275/dhclient
   udp6       0      0 [::]:53816              [::]:*                              802/avahi-daemon: r
   udp6       0      0 [::]:mdns               [::]:*                              802/avahi-daemon: r

fastcgi_params

    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         $document_root$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           $document_root;
    fastcgi_param   SERVER_PROTOCOL         $server_protocol;

    fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
    fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

    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;

    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param   REDIRECT_STATUS         200;
    ~                                                                                                                                                            
    ~                                                         
share|improve this question
    
Could you provide a sample URL and the fastcgi_params file? –  tmehlinger Mar 6 '12 at 4:33
    
sample url localhost/webv1/index.php –  johnny Mar 6 '12 at 9:16
    
Which version of nginx are you using?. Is the same in your laptop? –  erickzetta Mar 6 '12 at 12:49
    
0.8.54-4 I installed it from the repositories on both machines. I think i'll try installing a more recent version next (unfortunately I'm currently away from my other pc (the one with the problem)) –  johnny Mar 6 '12 at 13:19
add comment

1 Answer

Try commenting out the try_files directive. Are there any other virtual hosts defined which may be overriding this one?

share|improve this answer
    
thanks for the advice, but I have since updated nginx on my other machine and got it working. nginx also changed the config quite a bit, so now all directives are in nginx.conf. –  johnny Mar 26 '12 at 10:32
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.