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"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM