下載源碼包,解壓縮。
下載地址: http://nginx.org/en/download.htmlhtml
檢查和安裝依賴項,執行shellnginx
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel # 依賴工具說明: # gcc 編譯器 # pcre 正則表達式工具 # zlib 傳輸內容壓縮 # openssl Https支持
進入源碼包,執行配置命令正則表達式
./configure --prefix=/usr/local
執行編譯安裝shell
sudo make && make install # make 編譯 # make install 在編譯完成後, 把文件安裝至指定目錄, 這裏是/usr/local
在nginx安裝後的sbin目錄下執行工具
./nginx
./nginx -s stop
./nginx -s reload
ps aux |grep nginx
結果形如code
root 7558 0.0 0.0 24520 1568 ? Ss 14:05 0:00 nginx: master process ./nginx nobody 7692 0.0 0.0 25216 2188 ? S 15:51 0:00 nginx: worker process leo 7817 0.0 0.0 103260 848 pts/0 S+ 18:08 0:00 grep nginx # master proccess爲主進程 守護進程 # worker proccess爲工做進程, 用於響應請求
編輯文件 /etc/rc.d/rc.local
htm
填寫nginx啓動命令進程
/usr/local/nginx/sbin/nginx