Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


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...

share|improve this question
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: – 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";
share|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.

share|improve this answer

Your Answer


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.