server {
        listen *:8080;

        location / {
                root   /var/www/default/pub;
                index index.php;

                # if file exists return it right away
                if (-f $request_filename) {

                if (!-e $request_filename) {
                        rewrite ^(.+)$ /index.php$1 last;

        # serve static files directly
         location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
         access_log off;
         expires max;

  location ~* \.php$ {
    # By all means use a different server for the fcgi processes if you need to
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    include /usr/local/nginx/conf/fastcgi_params;

  location ~ /\.ht {
    deny  all;
} loads just fine... downloads...

  • You listen on 8080 so neither of those URLs ever touch Nginx. Also when you do starting using Nginx PHP won't work at all due to some basic mistake. I highly suggest you read my primer to get an understanding of the Nginx configuration file: blog.martinfjordvald.com/2010/07/nginx-primer – Martin Fjordvald Feb 6 '11 at 7:43
  • i have varnish in front of nginx doing caching and it runs on port 80 – Sam Williams Feb 6 '11 at 17:58

Your vhost work well(but port 8080):

# curl localhost:8080/public_/html/index.php


echo "123";
| improve this answer | |

Your location block that sends php files to fpm is outside of your server block (due to an extra '}' ).... So, of course, nginx is not going to pass the file to php-fpm but rather just serve it up as is, which is basically the symptom you are describing.

That said, there are some other issues too with your configuration, but unrelated to the problem at hand...


location ~* \.php$ {

remove that extra '}' above 'location' and see if that resolves the issue.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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