0

vhost:

server { listen *:8080; location / { root /var/www/default/pub; index index.php; # if file exists return it right away if (-f $request_filename) { break; } if (!-e $request_filename) { rewrite ^(.+)$ /index.php$1 last; break; } } # 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_pass 127.0.0.1:9000; 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; } } 

http://192.168.135.128/index.php loads just fine...

http://192.168.135.128/public_/html/index.php downloads...

2
  • 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 Commented Feb 6, 2011 at 7:43
  • i have varnish in front of nginx doing caching and it runs on port 80 Commented Feb 6, 2011 at 17:58

2 Answers 2

1

Your vhost work well(but port 8080):

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

/var/www/default/pub/public_/html/index.php:

<?php echo "123"; ?> 
0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.