2016-06-21 240 views
1

如果我连接www.my-hsot.com,则始终输出'Hello!' Text ..无法修改nginx index.html文件

但是我的index.html文件内容没有任何内容。我想只是空白页.. 我如何修改默认索引文件?

这里是我的默认配置:

server { 
    listen 80; 

    root /home/me; 
    index index.php index.html index.htm; 

    server_name www.my-hsot.com; 

    location/{ 
     try_files $uri $uri/ /index.php?$request_uri; 
    } 

    location /.well-known { 
     root /home/me/well-known; 
    } 


    location ~ \.php$ { 
     include     fastcgi_params; 
     fastcgi_keep_conn on; 
     fastcgi_index   index.php; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_intercept_errors on; 
     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
    } 
} 

这是nginx的默认索引文件(路径:/usr/share/nginx/html/index.html)is:

<!DOCTYPE html> 
<html> 
<head> 
<title>Welcome to nginx!</title> 
<style> 
    body { 
     width: 35em; 
     margin: 0 auto; 
     font-family: Tahoma, Verdana, Arial, sans-serif; 
    } 
</style> 
</head> 
<body> 
<h1>Welcome to nginx!</h1> 
<p>If you see this page, the nginx web server is successfully installed and 
working. Further configuration is required.</p> 

<p>For online documentation and support please refer to 
<a href="http://nginx.org/">nginx.org</a>.<br/> 
Commercial support is available at 
<a href="http://nginx.com/">nginx.com</a>.</p> 

<p><em>Thank you for using nginx.</em></p> 
</body> 
</html> 

回答

2

你已设置

root /home/me; 
index index.php index.html index.htm; 
... 
location/{ 
    try_files $uri $uri/ /index.php?$request_uri; 
} 

所以,当访问/ nginx的将首先查找其传递给FCGI处理程序的index.php。我想这就是“你好!”的地方来自:你的index.php。

如果没有index.php,它会查找index.html,但是在文档根目录/ home/me中。

为了得到一个空白页上/你可以使用类似的目录index.php文件

location ~ "^[/]?$" { 
    return 200; 
} 
+0

'/家庭/ me'是不存在的... –