1.編輯配置文件html
sudo vim /etc/nginx/nginx.conf
在http {}中添加以下nginx
server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } }
2.重啓nginxvim
systemctl restart nginx
3.訪問,成功bash
localhost:80/index.html
4.訪問日誌rest
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"