第一步配置nginx.conf

   

server {
        listen       80;
        server_name  localhosttest.com;
        #新配置的root路径
        root         /usr/html/wwww;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
           #注释掉原root路径,使用上面配置的root路径
           # root   html;
            index  index.html index.htm;
        }
        #匹配错误页面
        error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            #root   html;
        }

   第二步配置新的root

[root@localhost wwww]# mkdir /usr/html/wwww -pv
[root@localhost wwww]# vim index.html
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>New Document</title>
    <meta name="generator" content="EverEdit" />
    <meta name="author"  content="" />
    <meta name="keywords" content="" />
    <meta name="description" content=""  />
</head>
<body>
<h>这是第一个HTML</h>
                   
</body>
</html>

   第三步配置hosts

[root@localhost wwww]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 localhosttest.com
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

   第四步重启Nginx:

[root@localhost nginx]# kill -HUP $(cat /var/run/nginx/nginx.pid)
访问:http://localhosttest.com