# Nginx 非同步框架的網頁伺服器,也可以用作反向代理、負載平衡器和HTTP快取 ## 安裝 Nginx ```bash # 安裝 $ sudo apt update $ sudo apt install nginx # 檢查 Nginx 是否已經成功安裝並開始運作 # 在瀏覽器中輸入您的伺服器 IP,如果看到歡迎頁面,表示 Nginx 已經成功運作。 $ sudo systemctl status nginx # 每當修改了 Nginx 的設定檔案後,我們都需要重新載入或重啟 Nginx,讓新的設定生效 $ sudo systemctl reload nginx # 或 $ sudo systemctl restart nginx ``` ### 停止服務 ```bash # 立即停止服務 $ nginx -s stop # systemctl 停止 $ systemctl stop nginx.service # killall 方法殺死進程 $ killall nginx ``` ### 啟動Nginx ```bash # 直接啟動 $ nginx # systemctl 指令啟動 $ systemctl start nginx.service ``` ### 查看啟動記錄 ```bash $ ps aux|grep nginx ``` ### 重啟Nginx服務 ```bash $ systemctl restart nginx.service ``` ### 重新載入設定檔 ```bash $ nginx -s reload ``` ### 查看連接埠 ```bash $ netstat -tlnp ``` ## 相關文章參考 * [Nginx 是什麼?認識 Web Server 與 Nginx入門教學](https://tw.alphacamp.co/blog/nginx) * [Nginx 教學 一款強大且簡單設定的 Web Server](https://hi-founder.com/p/nginx-教學/) * [nginx 使用子網域部署多個網站](https://penueling.com/線上學習/nginx-使用子網域部署多個網站/) * [nginx的停止服務&命令](https://blog.51cto.com/u_15127518/4523655) * [Nginx | hackmd 筆記](https://hackmd.io/@CSIneD0STRmGlODbThwELw/SJuO29pr6)