Nginx 添加模塊

基于源碼安裝

#下載nginx 最新穩(wěn)定版本
wget http://nginx.org/download/nginx-1.14.0.tar.gz

#解壓
tar -zxvf nginx-1.14.0.tar.gz

# 全部采用默認安裝
./configure & make & make install  
make   & make install 

執(zhí)行完成之后 nginx 運行文件 就會被安裝在 /usr/local/nginx 下。

基于參數(shù)構(gòu)建

./configure

模塊更新

# 添加狀態(tài)查查看模塊
./configure --with-http_stub_status_module 

# 重新創(chuàng)建主文件
make

# 將新生成的nginx 文件覆蓋 舊文件。
make install

# 查看是否更新成功 顯示了 configure 構(gòu)建參數(shù)表示成功
/usr/local/nginx/sbin/nginx -V

Nginx 常用命令

  • 重載配置文件
    nginx -s reload
  • 立刻停止服務(wù)
    nginx -s stop
  • 優(yōu)雅的停止服務(wù)
    nginx -s quit
  • 重新開始記錄日志文件
    nginx -s reopen

Nginx 進程模型

liu@liu-VirtualBox:/etc/nginx$ ps aux | grep nginx
root      2454  0.0  0.0 124976  1412 ?        Ss   07:22   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  2455  0.0  0.1 125336  3180 ?        S    07:22   0:00 nginx: worker process
liu      27881  0.0  0.0 15984   1088 pts/4    S+   07:49   0:00 grep --color=auto nginx

master : 表示主進程
worker:表示工作進行

如何配置worker進程 ?修改nginx配置文件

user www-data;
# worker_processes auto;
# 配置2個worker進程
worker_processes 2;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

修改完成以后,我們可以使用 nginx -t 檢查語法是否正確

liu@liu-VirtualBox:/etc/nginx$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

然后使用命令nginx-s reload 重新加載配置文件

然后我們再次查看進程數(shù)

liu@liu-VirtualBox:/etc/nginx$ ps aux | grep nginx
root      2454  0.0  0.2 125120  4180 ?        Ss   07:22   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 27940  0.0  0.1 125448  3288 ?        S    07:59   0:00 nginx: worker process
www-data 27941  0.0  0.1 125448  3288 ?        S    07:59   0:00 nginx: worker process
liu      27948  0.0  0.0  15984   940 pts/4    S+   07:59   0:00 grep --color=auto nginx

nginx 默認采用epoll事件模型

events {
        # 每個worker允許連接的客戶端最大連接數(shù)
        worker_connections 768;
        # 默認采用epoll模型
        # multi_accept on;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容