?????博主簡介
????云計算領(lǐng)域優(yōu)質(zhì)創(chuàng)作者
????華為云開發(fā)者社區(qū)專家博主
????阿里云開發(fā)者社區(qū)專家博主
??交流社區(qū):運維交流社區(qū) 歡迎大家的加入!
?? 希望大家多多支持,我們一起進(jìn)步!??
??如果文章對你有幫助的話,歡迎 點贊 ???? 評論 ?? 收藏 ?? 加關(guān)注+??

一、下載安裝包
官網(wǎng)下載地址:nginx: download
選擇Stable version
版本下載到本地(該版本為Linux版本),下載完成后上傳到服務(wù)器上;
- 或者在服務(wù)器上使用wget下載
wget https://nginx.org/download/nginx-1.24.0.tar.gz
二、部署Nginx服務(wù)
1、安裝Nginx服務(wù)需要的依賴包
yum -y install gcc gcc-c++ zlib zlib-devel pcre-devel openssl openssl-devel
2、上傳解壓
(1)sz先把nginx壓縮包復(fù)制到虛擬機/服務(wù)器上
(2)解壓nginx壓縮包:
tar xf nginx-1.24.0.tar.gz -C /usr/src/
(3)切換到nginx目錄下:
cd /usr/src/nginx-1.24.0
3、編譯安裝nginx服務(wù)
指定安裝路徑然后編譯安裝
./configure --prefix=/usr/local/nginx
make
make install
#或者使用下面這一條命令。上面的看著清晰,在哪里錯了,易排查問題
./configure --prefix=/usr/local/nginx && make && make install
三、啟動及確認(rèn)服務(wù)是否正常
- 安裝成功后,啟動Nginx服務(wù):到/usr/local/nginx/sbin目錄下,啟動服務(wù):
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- 啟動成功后,查看進(jìn)程
ps -ef | grep nginx
- 或者查看端口是否啟動(默認(rèn)端口為80)
netstat -anput | grep 80
確定啟動之后,頁面訪問:ip
即可訪問到頁面:
四、nginx啟動、停止、重啟、檢測配置命令
#啟動nginx服務(wù)
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#停止nginx
/usr/local/nginx/sbin/nginx -s stop
#重啟nginx
/usr/local/nginx/sbin/nginx -s reload
#檢測nginx服務(wù)配置是否有誤
/usr/local/nginx/sbin/nginx -t
五、常見問題
報錯1:./configure: error: C compiler cc is not found
完整報錯:
./configure: error: C compiler cc is not found
原因:沒有編譯環(huán)境
解決:yum -y install gcc gcc-c++
報錯2:./configure: error: the HTTP rewrite module requires the PCRE library.
完整報錯:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
原因:缺少pcre-devel庫
解決:yum -y install pcre-devel
問題3:./configure: error: the HTTP gzip module requires the zlib library.
完整報錯:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
原因:缺少zlib-devel
解決:yum -y install zlib-devel
六、nginx配置模塊詳解
這里的圖是二進(jìn)制安裝默認(rèn)的配置,yum安裝的與二進(jìn)制安裝的nginx,配置會有差異,但整體大概的說明都是一樣的。
主要區(qū)域講解:
七、相關(guān)文章
文章標(biāo)題 | 文章連接 |
---|---|
【Linux】nginx基礎(chǔ)篇 – 介紹及yum安裝nginx | https://liucy.blog.csdn.net/article/details/133928000 |
【Linux】環(huán)境下部署Nginx服務(wù) - 二進(jìn)制部署方式 | https://liucy.blog.csdn.net/article/details/132145067 |
nginx配置負(fù)載均衡–實戰(zhàn)項目(適用于輪詢、加權(quán)輪詢、ip_hash) | https://liucy.blog.csdn.net/article/details/133986013 |
nginx快速部署一個網(wǎng)站服務(wù) + 多域名 + 多端口 | https://liucy.blog.csdn.net/article/details/133986102 |
八、推薦一個自動生成nginx配置文件的網(wǎng)站
https://nginxconfig.io/
可以根據(jù)你的業(yè)務(wù)需求,自動生成負(fù)載的配置。
往下面翻,就可以看到配置文件了;文章來源:http://www.zghlxwxcb.cn/news/detail-717995.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-717995.html
到了這里,關(guān)于【Linux】環(huán)境下部署Nginx服務(wù) - 二進(jìn)制部署方式的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!