centos 安裝 nginx

1. 下載 nginx 包

cd /usr/local
wget http://nginx.org/download/nginx-1.17.0.tar.gz

2. 安裝 nginx 依賴庫

yum install gcc-c++
yum install pcre
yum install pcre-devel
yum install zlib
yum install zlib-devel
yum install openssl
yum install openssl-devel

3. 解壓安裝包

tar -zxvf nginx-1.17.0.tar.gz

4. 進(jìn)入文件夾

cd nginx-1.17.0

5. 執(zhí)行# ./configure

./configure

6. 執(zhí)行make和make install編譯nginx

make
make install

7. 進(jìn)入 nginx 啟動目錄

cd /usr/local/nginx/sbin/
./nginx

項(xiàng)目就啟動起來了
有時(shí)候需要重啟服務(wù)器,才能生效

后續(xù)配置了HTTPS證書,可能會產(chǎn)生SSL包缺失的問題

nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf

解決如下:

1. 配置包

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

2. 配置完包后,make安裝,這里不要make install

make

3. 備份原有已安裝好的nginx

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

4. 然后將剛剛編譯好的nginx覆蓋掉原有的nginx(這個(gè)時(shí)候nginx要停止?fàn)顟B(tài))

cp ./objs/nginx /usr/local/nginx/sbin/

5. 然后啟動nginx,仍可以通過命令查看是否已經(jīng)加入成功

./nginx

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

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

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