nginx 安裝目錄 /usr/local/etc
nginx.conf目錄 /usr/local/etc/nginx/nginx.conf
nginx web根目錄 /usr/local/var/www/
//後期新增
nginx server配置目錄 /usr/local/etc/nginx/servers
nginx 錯誤總結
1.nginx -s stop出現
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied)
sudo chmod a+w /usr/local/var/log/nginx/*.log
sudo chmod a+w /usr/local/var
sudo chmod a+w /usr/local/var/run
出處:https://stackoverflow.com/questions/42605202/how-do-i-configure-nginx-to-put-its-error-log-file-somewhere-i-have-write-privil
2.nginx -s stop出現
nginx: [alert] kill(2040, 15) failed (1: Operation not permitted)
sudo nginx -s stop
3. nginx -s reload出現
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
重新啟動nginx(在nginx啟動時候會生成nginx.pid檔案,在nginx關閉會刪除該檔案,nginx重啟也會去查詢該檔案,若找不到,啟動nginx重新生成該檔案)
4.sudo nginx 啟動出現
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
刪除/usr/local/var/run/nginx.pid檔案
重新啟動