摘要:環(huán)境新系統(tǒng)首先使用命令下載的源碼包,并解壓為了安全添加用戶和組,以便以后以用戶的身份運(yùn)行程序,而非開始執(zhí)行腳本,進(jìn)行編譯前的配置配置腳本有很多的參數(shù),這里就只列出幾個(gè)常用的安裝目錄獲取更多配置使用命令提示編譯器未找到。
###環(huán)境:CentOS Linux release 7.5.1804 (Core) 新系統(tǒng)
0.首先使用wget命令下載nginx的源碼包,并解壓
[root@localhost ~]# wget http://nginx.org/download/nginx-1.15.5.tar.gz --2018-11-06 16:59:08-- http://nginx.org/download/nginx-1.15.5.tar.gz Resolving nginx.org (nginx.org)... 206.251.255.63, 95.211.80.227, 2606:7100:1:69::3f, ... Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1024791 (1001K) [application/octet-stream] Saving to: ‘nginx-1.15.5.tar.gz’ 100%[======================================================================================>] 1,024,791 245KB/s in 4.1s 2018-11-06 16:59:13 (245 KB/s) - ‘nginx-1.15.5.tar.gz’ saved [1024791/1024791] [root@localhost ~]# tar -xf nginx-1.15.5.tar.gz [root@localhost ~]# ls nginx-1.15.5 nginx-1.15.5.tar.gz [root@localhost ~]# cd nginx-1.15.5/ [root@localhost nginx-1.15.5]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
1.為了安全添加nginx用戶和組,以便以后以nginx用戶的身份運(yùn)行nginx程序,而非root
[root@localhost nginx-1.15.5]# useradd nginx -s /sbin/nologin
2.開始執(zhí)行configure腳本,進(jìn)行編譯前的配置 #configure配置腳本有很多的參數(shù),這里就只列出幾個(gè)常用的:--prefix:安裝目錄 --user -group. 獲取更多配置使用 ./configure --help命令
[root@localhost nginx-1.15.5]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-stream checking for OS + Linux 3.10.0-862.el7.x86_64 x86_64 checking for C compiler ... not found ./configure: error: C compiler cc is not found ###提示C編譯器未找到。我們安裝gcc編譯器重新嘗試 [root@localhost nginx-1.15.5]# yum -y install gcc [root@localhost nginx-1.15.5]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-stream checking for PCRE library in /usr/local/ ... not found checking for PCRE library in /usr/include/pcre/ ... not found checking for PCRE library in /usr/pkg/ ... not found checking for PCRE library in /opt/local/ ... not found ./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=option. ###此時(shí)又提示HTTP重定向模塊需要PCRE庫,你可以使用--without-http_rewirte_module命令把這個(gè)默認(rèn)安裝的模塊屏蔽掉,或者安裝PCRE庫文件,或者創(chuàng)建PCRE庫使用--with-pcre選項(xiàng)來指定位置,這里我們選擇安裝庫文件 [root@localhost nginx-1.15.5]# yum -y install pcre-devel [root@localhost nginx-1.15.5]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-stream 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= option. ###又提示OpenSSL沒有,沒辦法編譯就是這么麻煩,繼續(xù)裝包吧 [root@localhost nginx-1.15.5]# yum -y install openssl-devel [root@localhost nginx-1.15.5]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-stream Configuration summary + using system PCRE library + using system OpenSSL library + using system zlib library 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" ###此時(shí)配置成功,出現(xiàn)了配置信息
3.進(jìn)行編譯并復(fù)制文件到相應(yīng)目錄
[root@localhost nginx-1.15.5]# make && make install ###此時(shí)會(huì)出現(xiàn)一堆信息,無視就好,warning和error除外! [root@localhost ~]# ls /usr/local/nginx/ conf html logs sbin ###nginx安裝完成!?。?
4.啟動(dòng)nginx進(jìn)行訪問測(cè)試
[root@localhost nginx]# ./sbin/nginx [root@localhost nginx]# netstat -nutlp | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 44202/nginx: master ###查看到nginx進(jìn)程正在監(jiān)聽80端口即為成功,下面進(jìn)行curl訪問測(cè)試,web頁面也可以,更直觀 [root@localhost nginx]# curl http://127.0.0.1Welcome to nginx! Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.Thank you for using nginx.
###看到welcome to nginx!即為成功。
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/8100.html
摘要:環(huán)境新系統(tǒng)首先使用命令下載的源碼包,并解壓為了安全添加用戶和組,以便以后以用戶的身份運(yùn)行程序,而非開始執(zhí)行腳本,進(jìn)行編譯前的配置配置腳本有很多的參數(shù),這里就只列出幾個(gè)常用的安裝目錄獲取更多配置使用命令提示編譯器未找到。 ###環(huán)境:CentOS Linux release 7.5.1804 (Core) 新系統(tǒng) 0.首先使用wget命令下載nginx的源碼包,并解壓 [root@...
摘要:前言本文講解的是做為前端開發(fā)人員,對(duì)服務(wù)器的了解還是小白的我,是如何一步步將項(xiàng)目部署在阿里云的服務(wù)器上,并進(jìn)行性能優(yōu)化,達(dá)到頁面秒內(nèi)看到,秒內(nèi)看到首屏內(nèi)容的。搭建的項(xiàng)目是采用了主流的前后端分離思想的,這里只講服務(wù)器環(huán)境搭建與性能優(yōu)化。 showImg(https://segmentfault.com/img/remote/1460000017143281); 前言 本文講解的是:做為前...
閱讀 581·2021-11-18 10:02
閱讀 1063·2021-11-02 14:41
閱讀 690·2021-09-03 10:29
閱讀 1905·2021-08-23 09:42
閱讀 2749·2021-08-12 13:31
閱讀 1213·2019-08-30 15:54
閱讀 1967·2019-08-30 13:09
閱讀 1440·2019-08-30 10:55