Nginx發布靜態資源
- 一、步驟
- 二、實作發布html檔案
- 1.創建html資源目錄
- 2.配置Nginx組態檔
- 3.啟動Nginx
- 4.啟動成功
- 5.注意
一、步驟
- 將準備好的靜態資源檔案放在指定檔案夾
- 更改nginx的組態檔:nginx.conf
- 啟動nginx服務:start nginx (一定要切換到nginx的目錄下)
- 在瀏覽器中檢查是否發布成功
二、實作發布html檔案
1.創建html資源目錄

2.配置Nginx組態檔

#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
gzip on;
#靜態檔案
server {
listen 8080;
server_name localhost;
location / {
root D:/resources/statichtmls;
}
}
#html檔案
server {
#Nginx埠號
listen 8080;
server_name 127.0.0.1 localhost;
location / {
#Nginx配置靜態資源路徑
root D:/resources/statichtmls;
#Nginx首頁規范
index index.html index.htm;
}
}
}
3.啟動Nginx

4.啟動成功

5.注意
備注:測驗完成后記得一定要關閉Nginx
關閉指令nginx -s stop
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/249453.html
標籤:其他
上一篇:留言板 / 活動
