成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

CentOS7.4下安裝nginx的步驟是什么

這篇文章給大家介紹CentOS 7.4下安裝nginx的步驟是什么,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

吉利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證書合作)期待與您的合作!

一、安裝nginx依賴的軟件

nginx是C寫的,需要用GCC編譯;nginx中的rewrite module需要PCRE;nginx中的gzip module需要zlib;nginx中的HTTP SSL module需要OpenSSL。

已安裝的GCC版本信息如下:

 [root@VM_2_13_centos ~]# gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper

Target: x86_64-redhat-linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux

Thread model: posix

gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)

 

1、zlib源碼安裝:

zlib下載官網(wǎng):http://www.zlib.net/

下載zlib最新版本1.2.11源碼:

 [root@VM_2_13_centos stalker]# wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz  

解壓并進(jìn)入zlib代碼根目錄:

[root@VM_2_13_centos stalker]# tar zxvf zlib-1.2.11.tar.gz  

[root@VM_2_13_centos stalker]# cd zlib-1.2.11  

配置、編譯、安裝:

[root@VM_2_13_centos zlib-1.2.11]# ./configure  

[root@VM_2_13_centos zlib-1.2.11]# make  

[root@VM_2_13_centos zlib-1.2.11]# make install  

rm -f /usr/local/lib/libz.a  

cp libz.a /usr/local/lib  

chmod 644 /usr/local/lib/libz.a  

cp libz.so.1.2.11 /usr/local/lib  

chmod 755 /usr/local/lib/libz.so.1.2.11  

rm -f /usr/local/share/man/man3/zlib.3  

cp zlib.3 /usr/local/share/man/man3  

chmod 644 /usr/local/share/man/man3/zlib.3  

rm -f /usr/local/lib/pkgconfig/zlib.pc  

cp zlib.pc /usr/local/lib/pkgconfig  

chmod 644 /usr/local/lib/pkgconfig/zlib.pc  

rm -f /usr/local/include/zlib.h /usr/local/include/zconf.h  

cp zlib.h zconf.h /usr/local/include  

chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h  

[root@VM_2_13_centos zlib-1.2.11]# whereis zlib  

zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz  


2、PCRE源碼安裝:

PCRE官網(wǎng):http://www.pcre.org/

下載PCRE最新版本8.41源碼:

 [root@VM_2_13_centos stalker]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz  

解壓并進(jìn)入PCRE代碼根目錄:

[root@VM_2_13_centos stalker]# tar zxvf pcre-8.41.tar.gz  

[root@VM_2_13_centos stalker]# cd pcre-8.41  

配置、編譯、安裝:

[root@VM_2_13_centos pcre-8.41]# ./configure  

[root@VM_2_13_centos pcre-8.41]# make  

[root@VM_2_13_centos pcre-8.41]# make install  

查看版本:

[root@VM_2_13_centos pcre-8.41]# pcre-config --version  

8.41  

說明安裝成功。

3、OpenSSL源碼安裝:

OpenSSL官網(wǎng):https://www.openssl.org/

下載OpenSSL版本1.0.2n源碼:

[root@VM_2_13_centos stalker]# wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz  

解壓并進(jìn)入openssl代碼根目錄:

[root@VM_2_13_centos stalker]# tar zxvf openssl-1.0.2n.tar.gz  

[root@VM_2_13_centos stalker]# cd openssl-1.0.2n  

配置、編譯、安裝:

[root@VM_2_13_centos openssl-1.0.2n]# ./config  

[root@VM_2_13_centos openssl-1.0.2n]# make  

[root@VM_2_13_centos openssl-1.0.2n]# make install  



二、源碼安裝nginx

下載nginx最新穩(wěn)定版本1.12.2源碼:

[root@VM_2_13_centos stalker]# wget wget http://nginx.org/download/nginx-1.12.2.tar.gz  


解壓并進(jìn)入nginx代碼根目錄:

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

[root@VM_2_13_centos stalker]# cd nginx-1.12.2  

配置:

[root@VM_2_13_centos nginx-1.12.2]# ./configure --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11  

./configure之后的正確信息如下:

Configuration summary  

  + using PCRE library: ../pcre-8.41  

  + using system OpenSSL library  

  + using zlib library: ../zlib-1.2.11  

  nginx path prefix: "/usr/local/nginx"  

  nginx binary file: "/usr/local/nginx/sbin/nginx"  

  nginx modules path: "/usr/local/nginx/modules"  

  nginx configuration prefix: "/usr/local/nginx/conf"  

  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"  

  nginx pid file: "/usr/local/nginx/logs/nginx.pid"  

  nginx error log file: "/usr/local/nginx/logs/error.log"  

  nginx http access log file: "/usr/local/nginx/logs/access.log"  

  nginx http client request body temporary files: "client_body_temp"  

  nginx http proxy temporary files: "proxy_temp"  

  nginx http fastcgi temporary files: "fastcgi_temp"  

  nginx http uwsgi temporary files: "uwsgi_temp"  

  nginx http scgi temporary files: "scgi_temp"  

如果./configure提示OpenSSL找不到:

checking for OpenSSL library ... not found  

checking for OpenSSL library in /usr/local/ ... not found  

checking for OpenSSL library in /usr/pkg/ ... not found  

checking for OpenSSL library in /opt/local/ ... not found  

./configure: error: SSL modules require the OpenSSL library.  

You can either do not enable the modules, or install the OpenSSL library  

into the system, or build the OpenSSL library statically from the source  

with nginx by using --with-openssl=<path> option.  

按照提示說明,--with-openssl=<source path>即可。

[root@VM_2_13_centos nginx-1.12.2]# ./configure --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2n  

這樣就配置正確,信息如下:

Configuration summary  

  + using PCRE library: ../pcre-8.41  

  + using OpenSSL library: ../openssl-1.0.2n  

  + using zlib library: ../zlib-1.2.11  

  nginx path prefix: "/usr/local/nginx"  

  nginx binary file: "/usr/local/nginx/sbin/nginx"  

  nginx modules path: "/usr/local/nginx/modules"  

  nginx configuration prefix: "/usr/local/nginx/conf"  

  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"  

  nginx pid file: "/usr/local/nginx/logs/nginx.pid"  

  nginx error log file: "/usr/local/nginx/logs/error.log"  

  nginx http access log file: "/usr/local/nginx/logs/access.log"  

  nginx http client request body temporary files: "client_body_temp"  

  nginx http proxy temporary files: "proxy_temp"  

  nginx http fastcgi temporary files: "fastcgi_temp"  

  nginx http uwsgi temporary files: "uwsgi_temp"  

  nginx http scgi temporary files: "scgi_temp"  

編譯安裝:

[root@VM_2_13_centos nginx-1.12.2]# make  

[root@VM_2_13_centos nginx-1.12.2]# make install  

檢查nginx.conf配置正確性:

[root@VM_2_13_centos ~]# /usr/local/nginx/sbin/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:

[root@VM_2_13_centos ~]# /usr/local/nginx/sbin/nginx  

在瀏覽器中輸入主機(jī)IP地址看到如下的頁面說明nginx安裝成功

CentOS 7.4下安裝nginx的步驟是什么

nginx加入到開機(jī)自動啟動


先編輯系統(tǒng)啟動腳本vim /etc/rc.local 這個(gè)文件是系統(tǒng)啟動后會自動執(zhí)行的,我們就將啟動命令加入到這個(gè)文件中

 [root@VM_2_13_centos ~]# vim /etc/rc.local

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf & >/tmp/nginx.log 2>&1

查看nginx的進(jìn)程

[root@VM_2_13_centos ~]# ps -ef | grep nginx

root     16976 16360  0 18:03 pts/2    00:00:00 grep --color=auto nginx

root     25192     1  0 13:25 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx

nobody   25769 25192  0 13:37 ?        00:00:00 nginx: worker process

修改全局的環(huán)境變量

[root@VM_2_13_centos ~]# vim /etc/profile

export PATH=$PATH:/usr/local/MySQL/bin:/usr/local/nginx/sbin

Nginx的默認(rèn)安裝位置

/usr/local/nginx

/usr/local/nginx/conf/nginx.conf     //nginx的配置文件

/usr/local/nginx/html                //默認(rèn)的網(wǎng)頁文件

相關(guān)連接:

CentOS 7.4 搭建LNMP(Linux+Nginx+MySQL+PHP):

https://blog.csdn.net/u014558668/article/details/79314878

CentOS 7.4 使用yum源安裝PHP 5.4.16

https://blog.csdn.net/u014558668/article/details/79315641

CentOS 7下安裝MongoDB和php擴(kuò)展mongodb:

https://blog.csdn.net/username11211/article/details/52945488

CentOS 7下安裝php-redis擴(kuò)展及簡單使用:

https://blog.csdn.net/baidu_30000217/article/details/51481138

關(guān)于CentOS 7.4下安裝nginx的步驟是什么就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

分享名稱:CentOS7.4下安裝nginx的步驟是什么
網(wǎng)站URL:http://jinyejixie.com/article18/ggiddp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序網(wǎng)站設(shè)計(jì)公司、網(wǎng)站策劃、營銷型網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名
平和县| 义乌市| 剑河县| 全椒县| 嵊泗县| 枣强县| 莲花县| 儋州市| 芦溪县| 三都| 忻州市| 鱼台县| 兴仁县| 阿坝县| 增城市| 吉水县| 阜平县| 贡觉县| 阿鲁科尔沁旗| 许昌市| 芷江| 阳春市| 德令哈市| 汕尾市| 通河县| 平利县| 赤城县| 汝南县| 岚皋县| 镇安县| 建平县| 保德县| 安福县| 桐城市| 农安县| 沁源县| 磴口县| 长子县| 大洼县| 兰州市| 赫章县|