Nginx

Nginx 虛擬主機伺服器名,root

  • November 17, 2014

我安裝nginx-1.6.2,2FreeBSD-9.2-RELEASE-p5,這是我的配置:

# tail -2 nginx.conf
   include _includes/*.conf;
}
# cat _includes/XXX.conf 
server {
   server_name XXX;
   root    /home/user/XXX/;
   index   index.php;
   include _includes/_location-php.include;
}
# cat _includes/_location-php.include 
location ~ \.php$ {
   include fastcgi_params;
   fastcgi_intercept_errors on;
   fastcgi_pass    unix:/var/run/php-fpm.sock;
   fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# tail -1 /var/log/nginx-error.log 
2014/11/17 11:45:59 [error] 82950#0: *6 open() "/usr/local/www/nginx/admin.php" failed (2: No such file or directory), client: XX.XX.XX.XX, server: localhost, request: "GET /admin.php HTTP/1.1", host: "XXX"
# 

在另一個伺服器塊中root指向另一個(預設配置 - http://pastebin.com/caRJM20f/usr/local/www/nginx``server_name localhost

root為什麼它會像我為另一個指定的那樣接管我的server_name

您需要在文件中的部分listen [IP:]80;內部添加。server``_includes/XXX.conf

引用自:https://serverfault.com/questions/644967