mac系統下用nginx服務器部署頁面


1.安裝nginx(需要先安裝Homebrew)。使用命令

brew install nginx

安裝nginx。

 

2.用命令

open /usr/local/Cellar/nginx

用訪達打開安裝路徑。

 

3.打開bin文件夾,雙擊nginx文件,啟動nginx,然后訪問http://localhost:8080/

若出現如圖界面,則啟動nginx成功。

 

4.打開配置文件。用命令

open /usr/local/etc/nginx

打開配置文件所在路徑,再用文本編輯器打開nginx.conf文件進行編輯。

 

5.修改部署路徑為項目路徑。

如項目首頁路徑為/Users/luoyihao/projectName/main.html,projectName內包括項目用到的所有資源(包括圖片、css、js等),

則把第一個

location / {
    root   html;
    index  index.html index.htm;
}

修改為

location / {
    root   /Users/luoyihao/projectName;
    index  main.html;
}

 

6.重新啟動nginx,使用命令

nginx -s reload

然后訪問http://localhost:8080/main.html即可。

 

附:Windows系統下用nginx服務器部署頁面


免責聲明!

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



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