Nginx添加静态页面

1.编辑配置文件

sudo vim  /etc/nginx/nginx.conf

在http {}中添加如下

server {
                listen       80;
                server_name  localhost;
                location / {
                    root   html;
                    index  index.html index.htm;
                }
            }

 

 

2.重启nginx

systemctl restart nginx

3.访问,成功

localhost:80/index.html

 

4.访问日志

tail -n 100 /var/log/nginx/access.log 
127.0.0.1 - - [12/Oct/2019:18:22:21 +0800] "GET /index.html HTTP/1.1" 200 396 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
127.0.0.1 - - [12/Oct/2019:18:22:21 +0800] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
127.0.0.1 - - [12/Oct/2019:18:30:37 +0800] "GET /index.html HTTP/1.1" 200 396 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
127.0.0.1 - - [12/Oct/2019:18:30:37 +0800] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"

 

posted @ 2019-10-12 18:32  tonglin0325  阅读(1575)  评论(0编辑  收藏  举报