nginx虚拟主机不工作,所有的虚拟主机都转到默认主机

我只是在运行Ubuntu 10.10的VPS上做了一个干净安装的nginx + php-fpm,nginx正在服务,PHP运行正常,但是我不能添加虚拟主机。 那么,我可以添加它们,但只有一个有效,其余的就是这个第一个。

这是我的第一个虚拟主机,host1:

server { listen 80; server_name host1; access_log /var/log/nginx/host1.log; error_log /var/log/nginx/host1.error.log; location / { root /var/www/vhosts/host1/; index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME /var/www/vhosts/host1/$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_index index.php; } } 

第二个,host2:

 server { listen 80; server_name host2; access_log /var/log/nginx/host2.log; error_log /var/log/nginx/host2.error.log; location / { root /var/www/vhosts/host2/; index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME /var/www/vhosts/host2/$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_index index.php; } } 

问题是,当我去http:// host1一切都很好,但在http:// host2 ,它只是显示host1!

我没有安装Apache,一切都来自回购。 任何指针?

不知道你有什么错,但看看我的conf文件,它的工作。

 server { server_name localhost; root /opt/local/html; index index.php index.html index.htm; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /opt/local/html/$fastcgi_script_name; include /opt/local/etc/nginx/fastcgi.conf; } } server { server_name pma; root /opt/local/www/pma; index index.php index.html index.htm; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /opt/local/www/pma/$fastcgi_script_name; include /opt/local/etc/nginx/fastcgi.conf; } }