Subdomains nginx

Posted May 10, 2014 5.3k views
Hello! When i load my browser asks whether to save the file? Nginx subdomain conf ~~~~ server { listen 80; server_name; root /usr/share/nginx/www/test; index index.php index.html; location / { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ~~~~ This conf works great for non php files(e.g. index.html) What i need to do?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers
Hi, this is a solution for you:

server {
listen 80;
server_name test.*;
charset utf-8;

location / {
root /usr/share/nginx/www/test;
index index.html index.htm index.php;

location ~ \.php$ {
try_files $uri = 404;
root /usr/share/nginx/www/test;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME
$document_root $fastcgi_script_name;
fastcgi_intercept_errors on;
include /etc/nginx/fastcgi_params;

Leandro Naves
Hello! Thanks for answer. When i restart nginx its failed with error

invalid parameter "$fastcgi_script_name"
@Evgenity: Make sure that part is all on one line:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;