2018年3月29日 星期四

安裝 (nginx 一)

官網
此篇以 1.12.2 穩定版為主

※Linux (Fedora)

※安裝

pcre  pcre-devel 正則
zlib  zlib-devel

dnf install pcre
要有 root 權限才能安裝

tar -zxvf *.tar.gz
解壓完進去目錄做三步
1../configure 會產生一個檔案和一個資料夾,Makefile 和 objs
預設會安裝到 /usr/local/nginx,想改可用 --prefix 路徑

2.make,如果有失敗要再來一次,有可能會使用到 make distclean
3.make install

※操作

安裝完後在/usr/local/nginx 有很多東西,以後都要在這操作
/usr/local/nginx/sbin/ 有 nginx
.啟動 ./nginx,啟動後,預設會在 /usr/local/nginx/sbin/logs/ 生成 nginx.pid 檔案,裡面記錄 master pid,想改可在 /usr/local/nginx/conf/nginx.conf 修改
.關閉 ./nginx -s quit,nginx.pid 會刪除

-s 後可加的指令:
stop 關閉,不會等 session 離開
quit 關閉,會等 session 離開
reload 不用重啟就可以讀到新的設定檔 nginx.conf
reopen 重新打開 log 檔

信號:

TERM、INT 相當於 -s stop
QUIT 相當於 -s quit
HUP 相當於 -s reload
USR1 相當於 -s reopen
以下兩個 -s 沒有
USR2 升級 nginx 使用
WINCH 升級後關才舊的 worker process

例:
kill -INT(TERM) master process 的pid號
kill -INT 26666
ps -aux |grep nginx 可查到 pid 號

USR1的用法:假設一直有資料寫進 access.log
如果將 access.log 改名,還是會寫入
必需使用 kill -USR1 PID號

不想看 pid 可用如下的方法
cat logs/nignx.pid 裡面已經記錄了 pid 號
所以可用 kill -USR1 `cat logs/nignx.pid`



※Windows

和 linux 很不一樣,所有的東西都在解壓後的資料夾裡

※查看 pid

滑鼠:
執行打 taskmgr (在最下面按右鍵 --> 工作管理員) --> detail

指令:
1-1.tasklist |findstr /i nginx  :/i為忽略大小寫
1-2.tasklist |find /i "nginx"
2.tskill pid號

※必需先刪除 master pid 才能刪 worker pid,否則 worker pid 會自動生成其他的 pid號,通常 master pid 的容量比較小,要正確的就看 logs\nginx.pid

※沒有 linux 的信號功能

沒有留言:

張貼留言