日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS7.3編譯安裝Nginx1.12.2

1. Nginx簡介
Nginx (發(fā)音為[engine x])專為性能優(yōu)化而開發(fā),其最知名的優(yōu)點(diǎn)是它的穩(wěn)定性和低系統(tǒng)資源消耗,以及對并發(fā)連接的高處理能力(單臺(tái)物理服務(wù)器可支持30000~50000個(gè)并發(fā)連接), 是一個(gè)高性能的 HTTP 和反向代理服務(wù)器,也是一個(gè)IMAP/POP3/SMTP 代理服。

東臺(tái)ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

Linux系統(tǒng):centos 7.3

2. 安裝準(zhǔn)備
2.1 gcc安裝 

安裝 nginx 需要先將官網(wǎng)下載的源碼進(jìn)行編譯,編譯依賴 gcc 環(huán)境,如果沒有 gcc 環(huán)境,則需要安裝:

[root@nginx ~]# yum -y install gcc-c++

2.2 pcre安裝

PCRE(Perl Compatible Regular Expressions) 是一個(gè)Perl庫,包括 perl 兼容的正則表達(dá)式庫。nginx 的 http 模塊使用 pcre 來解析正則表達(dá)式,所以需要在 linux 上安裝 pcre 庫,pcre-devel 是使用 pcre 開發(fā)的一個(gè)二次開發(fā)庫。nginx也需要此庫。

[root@nginx ~]# yum  -y install  pcre pcre-devel

2.3 zlib安裝

zlib 庫提供了很多種壓縮和解壓縮的方式, nginx 使用 zlib 對 http 包的內(nèi)容進(jìn)行 gzip ,所以需要在 Centos 上安裝 zlib 庫。

[root@nginx ~]# yum -y install zlib zlib-devel

2.4 OpenSSL安裝

OpenSSL 是一個(gè)強(qiáng)大的安全套接字層密碼庫,囊括主要的密碼算法、常用的密鑰和證書封裝管理功能及 SSL 協(xié)議,并提供豐富的應(yīng)用程序供測試或其它目的使用。
nginx 不僅支持 http 協(xié)議,還支持 https(即在ssl協(xié)議上傳輸http),所以需要在 Centos 安裝 OpenSSL 庫。

[root@nginx ~]# yum -y install openssl openssl-devel

3. Nginx安裝

3.1 Nginx版本

下載網(wǎng)址:https://nginx.org/en/download.html

選擇最新的穩(wěn)定版nginx-1.12.2
版本說明:

Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以說是開發(fā)版
Stable version:最新穩(wěn)定版,生產(chǎn)環(huán)境上建議使用的版本
Legacy versions:遺留的老版本的穩(wěn)定版

3.2 Nginx下載

使用wget命令下載

[root@nginx ~]# wget -c https://nginx.org/download/nginx-1.12.2.tar.gz

如沒有wget命令則安裝:

[root@nginx ~]# yum -y install wget

3.3 解壓

[root@nginx ~]# tar -zxvf nginx-1.12.2.tar.gz

3.4 安裝配置

3.4.1 新建nginx用戶和組

[root@nginx include]# groupadd nginx
[root@nginx include]# useradd -g nginx -d /home/nginx nginx
[root@nginx include]# passwd nginx

3.4.2第三方模塊安裝

本文以安裝第三方模塊sticky為例,版本為1.,2.5,下載地址:

可以到主機(jī)寶貝資源站下載:

具體下載目錄在 /2018年資料/9月/27日/CentOS 7.3編譯安裝Nginx 1.12.2/

上傳解壓:

[root@nginx ~]# tar -zxvf nginx-goodies-nginx-sticky-module-ng-08a395c66e42..gz
[root@nginx ~]# mv nginx-goodies-nginx-sticky-module-ng-08a395c66e42 nginx-sticky-1.2.5

3.4.3 安裝

[root@nginx ~]# cd nginx-1.12.2
[root@nginx nginx-1.12.2]# ./configure --add-module=/root/nginx-sticky-1.2.5

指定用戶、路徑和模塊配置(可選):

./configure \
--user=nginx --group=nginx \          #安裝的用戶組
--prefix=/usr/local/nginx \          #指定安裝路徑
--with-http_stub_status_module \        #監(jiān)控nginx狀態(tài),需在nginx.conf配置
--with-http_ssl_module \            #支持HTTPS
--with-http_sub_module \            #支持URL重定向
--with-http_gzip_static_module          #靜態(tài)壓縮
--add-module=/root/nginx-sticky-1.2.5          #安裝sticky模塊

3.5 編譯

[root@nginx nginx-1.12.2]# make && make install

報(bào)錯(cuò):

/root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c: 在函數(shù)‘ngx_http_sticky_misc_sha1’中:
/root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:176:15: 錯(cuò)誤:‘SHA_DIGEST_LENGTH’未聲明(在此函數(shù)內(nèi)第一次使用)
  u_char hash[SHA_DIGEST_LENGTH];
              ^
/root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:176:15: 附注:每個(gè)未聲明的標(biāo)識(shí)符在其出現(xiàn)的函數(shù)內(nèi)只報(bào)告一次
/root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:176:10: 錯(cuò)誤:未使用的變量‘hash’ [-Werror=unused-variable]
  u_char hash[SHA_DIGEST_LENGTH];
          ^
/root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c: 在函數(shù)‘ngx_http_sticky_misc_hmac_sha1’中:
/root/nginx-sticky-1.2.5//ngx_http_sticky_misc.c:242:15: 錯(cuò)誤:‘SHA_DIGEST_LENGTH’未聲明(在此函數(shù)內(nèi)第一次使用)
  u_char hash[SHA_DIGEST_LENGTH];

解決方法:

修改ngx_http_sticky_misc.c文件,新增#include 和#include 模塊

[root@nginx nginx-1.12.2]# sed -i '12a #include ' /root/nginx-sticky-1.2.5/ngx_http_sticky_misc.c
[root@nginx nginx-1.12.2]# sed -i '12a #include ' /root/nginx-sticky-1.2.5/ngx_http_sticky_misc.c

重新編譯:

[root@nginx nginx-1.12.2]# make && make install

3.6 nginx命令全局執(zhí)行設(shè)置

[root@nginx bin]# cd /usr/local/nginx/sbin/
[root@nginx sbin]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

4. Nginx相關(guān)命令

4.1 版本查看

[root@nginx ~]# nginx  -v
nginx version: nginx/1.12.2

4.2 查看加載的模塊

[root@nginx ~]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
configure arguments: --add-module=/root/nginx-sticky-1.2.5/

4.3 啟停命令

4.3.1 啟動(dòng)

[root@nginx nginx-1.12.2]# nginx

4.3.2 停止

[root@nginx nginx-1.12.2]# nginx -s stop
[root@nginx nginx-1.12.2]# nginx -s quit

4.3.3 動(dòng)態(tài)加載

[root@nginx nginx-1.12.2]# ngins -s reload

4.3.4 測試配置文件nginx.conf正確性

[root@nginx ~]# nginx  -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

nginx -s quit:此方式停止步驟是待nginx進(jìn)程處理任務(wù)完畢進(jìn)行停止。
nginx -s stop:此方式相當(dāng)于先查出nginx進(jìn)程id再使用kill命令強(qiáng)制殺掉進(jìn)程。

nginx -s reload:動(dòng)態(tài)加載,當(dāng)配置文件nginx.conf有變化時(shí)執(zhí)行該命令動(dòng)態(tài)加載。

4.4 開機(jī)自啟動(dòng)

編輯/etc/rc.d/rc.local文件,新增一行/usr/local/nginx/sbin/nginx

[root@nginx rc.d]# cd /etc/rc.d
[root@nginx rc.d]# sed -i '13a /usr/local/nginx/sbin/nginx' /etc/rc.d/rc.local
[root@nginx rc.d]# chmod u+x rc.local

5. 更改默認(rèn)端口

編輯配置文件/usr/local/nginx/conf/nginx.conf,將默認(rèn)端口80修改為81:

[root@nginx ~]# view /usr/local/nginx/conf/nginx.conf

加載配置:

[root@nginx ~]# nginx -s reload

6. 訪問Nginx

6.1 關(guān)閉防火墻

[root@nginx ~]# firewall-cmd --state
running
[root@nginx ~]# systemctl stop firewalld.service
[root@nginx ~]# firewall-cmd --state
not running

6.2 訪問Nginx

http://localhost:81


網(wǎng)頁題目:CentOS7.3編譯安裝Nginx1.12.2
URL分享:http://www.5511xx.com/article/cdgseds.html