1. 程式人生 > >nginx 學習筆記 (一)

nginx 學習筆記 (一)

mac 上安裝 nginx - 解決一些莫名報錯

mac 上面可以直接使用 homebrew 來安裝,直接執行 brew install nginx ,一般來說就可以直接自動安裝完成了。毫無壓力。

如果你不幸像我一樣遇到各種報錯,恭喜!請繼續看!

報錯1 - No such file or directory @ dir_chdir - /usr/local/Cellar

我的解決方式 - 按照這個路徑來手動建立這個 Cellar 檔案

報錯2 - "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)

我的解決方式 - 執行 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

,手動設定一下配置檔案。如果執行了無效,按照這個路徑,新建好這個檔案,再執行一次。

報錯3 - 安裝好後,執行 nginx 失敗

我的解決方式 - 執行 brew link pcre

啟動、重啟、關閉 nginx 的命令

啟動

nginx

關閉

  • nginx -s quit
  • kill all
  • systemctl start nginx.service

重啟

nginx -s restart

檢視當前程序

  • ps aux | grep nginx