前言
確定環(huán)境是有網(wǎng)的環(huán)境,且yum源可用;
在【Nginx之正向代理與反向代理】一文中我們實現(xiàn)了將Nginx服務器作為正向代理服務器和反向代理服務器,但美中不足的是僅支持http協(xié)議,不支持https協(xié)議。
- http協(xié)議:協(xié)議以明文方式發(fā)送數(shù)據(jù),不提供任何方式的數(shù)據(jù)加密。不適合傳輸一些敏感信息,例如密碼。其使用的端口是80。
- https協(xié)議:在http協(xié)議的基礎(chǔ)上,加入了SSL(Secure Sockets Layer),用于對數(shù)據(jù)進行加密。其使用的端口為443
安裝nginx依賴
#安裝gcc
yum install gcc-c++
#安裝PCRE pcre-devel
yum install -y pcre pcre-devel
#安裝zlib
yum install -y zlib zlib-devel
#安裝Open SSL
yum install -y openssl openssl-devel
下載并解壓nginx安裝包和ngx_http_proxy_connect_module模塊
cd /home
mkdir softPackage
wget http://nginx.org/download/nginx-1.24.0.tar.gz
# 你也可以到網(wǎng)站選擇你所需要的版本
http://nginx.org/ 截至到筆者最新穩(wěn)定版為nginx-1.24.0
ngx_http_proxy_connect_module模塊開源地址:
https://github.com/chobits/ngx_http_proxy_connect_module/tags
目前最新版本為0.0.5
wget https://github.com/chobits/ngx_http_proxy_connect_module/archive/refs/tags/v0.0.5.tar.gz
或
wget https://ghproxy.com/https://github.com/chobits/ngx_http_proxy_connect_module/archive/refs/tags/v0.0.5.tar.gz
解壓nginx安裝包 和 ngx_http_proxy_connect_module模塊
cd /home/softPackage
tar -xvf nginx-1.24.0.tar.gz
cd /home/softPackage
tar -xvf ngx_http_proxy_connect_module-0.0.5.tar.gz
cp -r ngx_http_proxy_connect_module-0.0.5 /opt/ngx_http_proxy_connect_module
編譯ngx_http_proxy_connect_module模塊和安裝nginx
切記 編譯對應版本的patch文件如下圖
cd /home/softPackage/nginx-1.24.0
# 1、添加patch
patch -p1 < /opt/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_102101.patch
#
vi /opt/ngx_http_proxy_connect_module/config
# 輸入 :set ff 顯示fileformat=dos
:set ff
# 需要把格式修改為unix,方法是直接輸入:set ff=unix
:set ff=unix
# 保存退出
:wq
# 編譯 執(zhí)行命令
./configure --with-http_stub_status_module --with-stream --with-http_ssl_module --with-http_gzip_static_module --add-module=/opt/ngx_http_proxy_connect_module
# 執(zhí)行make命令和make install命令
make && make install
& 表示程序要在后臺運行。
方式:command1 &
&& 邏輯“與”,表示前一條命令執(zhí)行成功時,才執(zhí)行后一條命令;如果前面一條命令執(zhí)行失敗,后面的命令不再執(zhí)行。
方式:command1 && command2
編譯報錯
./configure --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/opt/ngx_http_proxy_connect_module
如下錯誤:
adding module in /opt/ngx_http_proxy_connect_module
/opt/ngx_http_proxy_connect_module/config: line 2: $‘\r’: command not found
/opt/ngx_http_proxy_connect_module/config: line 15: syntax error: unexpected end of file
was configuredxy_connect_module文章來源:http://www.zghlxwxcb.cn/news/detail-649347.html
感謝
這兩篇文章的,本文借鑒這兩篇文章加上自己經(jīng)驗,多有不足請同行指正。文章來源地址http://www.zghlxwxcb.cn/news/detail-649347.html
- Linux安裝nginx詳細步驟
- “syntax error: unexpected end of file”解決方案
到了這里,關(guān)于Linux 環(huán)境 nginx安裝的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!