1.安裝文件列表 2.安裝文件複製以下目錄 3.安裝gcc 4.安裝pcre依賴包 5.安裝libstdc++-devel(gcc-c++依賴) 6.安裝gcc-c++ 7.安裝zlib-devel 8.安裝nginx 9.開放80埠 10.查看埠開啟狀態 11.查看安裝路徑與nginx版本 1 ...
1.安裝文件列表
//gcc及其依賴包 cloog-ppl-0.15.7-1.2.el6.x86_64.rpm cpp-4.4.7-16.el6.x86_64.rpm gcc-4.4.7-16.el6.x86_64.rpm mpfr-2.4.1-6.el6.x86_64.rpm ppl-0.10.2-11.el6.x86_64.rpm //pcre依賴包 pcre-7.8-7.el6.x86_64.rpm pcre-devel-7.8-7.el6.x86_64.rpm //libstdc++-devel包(gcc-c++依賴) libstdc++-devel-4.4.7-16.el6.x86_64.rpm //gcc-c++包 gcc-c++-4.4.7-16.el6.x86_64.rpm //zlib-devel包 zlib-devel-1.2.3-29.el6.x86_64.rpm //nginx包 nginx-1.12.1.tar.gz
2.安裝文件複製以下目錄
/usr/local/src/
3.安裝gcc
[root@localhost src]# rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm warning: mpfr-2.4.1-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105 b9de: NOKEY Preparing... ########################################### [100%] 1:mpfr ########################################### [100%] [root@localhost src]# rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm warning: ppl-0.10.2-11.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c10 5b9de: NOKEY Preparing... ########################################### [100%] 1:ppl ########################################### [100%] [root@localhost src]# rpm -ivh cpp-4.4.7-16.el6.x86_64.rpm warning: cpp-4.4.7-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9 de: NOKEY Preparing... ########################################### [100%] 1:cpp ########################################### [100%] [root@localhost src]# rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm warning: cloog-ppl-0.15.7-1.2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:cloog-ppl ########################################### [100%] [root@localhost src]# rpm -ivh gcc-4.4.7-16.el6.x86_64.rpm warning: gcc-4.4.7-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9 de: NOKEY Preparing... ########################################### [100%] 1:gcc ########################################### [100%]
4.安裝pcre依賴包
//查看pcre本地版本 [root@localhost src]# rpm -qa pcre pcre-7.8-7.el6.x86_64 rpm -ivh pcre-7.8-7.el6.x86_64.rpm --force rpm -ivh pcre-devel-7.8-7.el6.x86_64.rpm
5.安裝libstdc++-devel(gcc-c++依賴)
[root@localhost src]# rpm -ivh libstdc++-devel-4.4.7-16.el6.x86_64.rpm warning: libstdc++-devel-4.4.7-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, k ey ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:libstdc++-devel ########################################### [100%]
6.安裝gcc-c++
[root@localhost src]# rpm -ivh gcc-c++-4.4.7-16.el6.x86_64.rpm warning: gcc-c++-4.4.7-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c1 05b9de: NOKEY Preparing... ########################################### [100%] 1:gcc-c++ ########################################### [100%]
7.安裝zlib-devel
[root@localhost src]# rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm warning: zlib-devel-1.2.3-29.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:zlib-devel ########################################### [100%]
8.安裝nginx
//解壓 [root@localhost src]# tar -vxzf nginx-1.12.1.tar.gz //解壓後進入nginx-1.12.1目錄下 [root@localhost src]# cd nginx-1.12.1 //執行./configure 預設安裝到/usr/local/nginx 或者執行./configure --prefix=/usr/local/nginx 指定安裝目錄 [root@localhost nginx-1.12.1]# ./configure checking for OS + Linux 2.6.32-573.el6.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) checking for gcc -pipe switch ... found ...... ...... ...... ...... ...... ...... Configuration summary + using system PCRE library + OpenSSL library is not used + 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" //執行make [root@localhost nginx-1.12.1]# make make -f objs/Makefile make[1]: Entering directory `/usr/local/src/nginx-1.12.1' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src /core -I src/event -I src/event/modules -I src/os/unix -I objs \ ...... ...... ...... ...... ...... ...... sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/usr/local/src/nginx-1.12.1' //執行make install [root@localhost nginx-1.12.1]# make install make -f objs/Makefile install make[1]: Entering directory `/usr/local/src/nginx-1.12.1' test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx' ...... ...... ...... ...... ...... ...... test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' make[1]: Leaving directory '/usr/local/src/nginx-1.12.1'
9.開放80埠
[root@localhost /]# vim /etc/sysconfig/iptables //添加以下內容 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT //重啟服務 [root@localhost /]# service iptables restart iptables:將鏈設置為政策 ACCEPT:filter [確定] iptables:清除防火牆規則: [確定] iptables:正在卸載模塊: [確定] iptables:應用防火牆規則: [確定]
10.查看埠開啟狀態
root@localhost /]# /etc/init.d/iptables status Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80 6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) num target prot opt source destination 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) num target prot opt source destination
11.查看安裝路徑與nginx版本
[root@localhost sbin]# rpm -qa pcre pcre-7.8-7.el6.x86_64 [root@localhost sbin]# whereis nginx nginx: /usr/local/nginx [root@localhost sbin]# /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.12.1
12.運行nginx
[root@localhost nginx-1.12.1]# cd /usr/local/nginx/sbin [root@localhost sbin]# ./nginx
13.重啟nginx
//更改配置重啟nginx kill -HUP //主進程號或進程號文件路徑 //或者使用 cd /usr/local/nginx/sbin ./nginx -s reload //判斷配置文件是否正確 nginx -t -c /usr/local/nginx/conf/nginx.conf //或者使用 cd /usr/local/nginx/sbin ./nginx -t
14.關閉nginx
查詢nginx主進程號 ps -ef | grep nginx 從容停止 kill -QUIT 主進程號 快速停止 kill -TERM 主進程號 強制停止 kill -9 nginx 若nginx.conf配置了pid文件路徑,如果沒有,則在logs目錄下 kill -信號類型 '/usr/local/nginx/logs/nginx.pid'