tonglin0325的个人主页

Nginx添加静态页面

1.编辑配置文件

1
2
sudo vim  /etc/nginx/nginx.conf

在http {}中添加如下

1
2
3
4
5
6
7
8
9
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}

 

 

2.重启nginx

1
2
systemctl restart nginx

3.访问,成功

1
2
localhost:80/index.html

 

4.访问日志

1
2
3
4
5
6
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"