摆脱“欢迎来到nginx!”

我刚刚在我的Ubuntu分段机器上安装了nginx。 inputhttp://192.168.1.1./index.php就像一个魅力,并加载我已经放在/var/www/public_html文件夹中的index.php文件。 http://192.168.1.1不过反而显示欢迎使用nginx! 页面,而不是我的index.php文件。

我究竟做错了什么? 这是我的nginxconfiguration:

 server { listen 80 default; root /var/www/public_html; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } } 

看看try_files的文档: http ://wiki.nginx.org/HttpCoreModule#try_files,你可能应该有这样的:

 location / { try_files $uri $uri/ /index.html /index.php; } 

看看Drupal,Wordpress,FastCGI等的例子

我猜你仍然有默认的网站configuration在启用网站,并且它的字母顺序sorting比你的自定义configuration更高。 默认configuration将会捕获任何没有已知主机头的请求,并使用index.html作为索引。