Nginx安裝

[root@Nginx10000 src]# cat /etc/redhat-release 
CentOS release 6.4 (Final)
[root@Nginx10000 src]# uname -r
2.6.32-358.el6.x86_64

首先要安裝Nginx依賴庫


pcre pcre-devel     因爲Nginx服務器可能有重寫Rewrite模塊 所以要用到正則表達式

openssl-devel      支持加密的https協議


第一步:先檢查 pcre pcre-devel openssl-devel 是否安裝 如果沒有安裝 則進行 yum install的方式進行安裝

[root@Nginx10000 ~]# rpm -qa pcre pcre-devel openssl-devel   //檢查是否安裝
pcre-7.8-6.el6.x86_64


看到上面的安裝情況 則說明 linux在安裝系統的 就幫我們安裝了一個 pcre-7.8-6.el6.x86_64

所以 我們還要自己安裝......開始準備工作吧!!!!!    騷年


一般我們要記住 如果系統提示說 少哪個 libary 就要想到是少庫文件 而庫文件的命名的方式是:某某某-devel 即可

[root@Nginx10000 ~]# pwd
/root
[root@Nginx10000 ~]# yum install pcre pcre-devel openssl-devel -y     //開始安裝
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, security

檢查是否安裝成功.......

[root@Nginx10000 ~]# rpm -qa pcre pcre-devel openssl-devel
pcre-devel-7.8-7.el6.x86_64
pcre-7.8-7.el6.x86_64
openssl-devel-1.0.1e-42.el6_7.4.x86_64




恭喜你 萬事俱備 只欠東風.......................................................


下載軟件:http://nginx.org/download/nginx-1.6.3.tar.gz

[root@Nginx10000 src]# pwd
/usr/local/src
[root@Nginx10000 src]# wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
[root@Nginx10000 src]# ll
total 788
-rw-r--r--. 1 root root 805253 Apr  8  2015 nginx-1.6.3.tar.gz

解壓軟件 nginx-1.6.3.tar.gz

tar xf nginx-1.6.3.tar.gz


查看一下Nginx目錄結構

[root@Nginx10000 nginx-1.6.3]# pwd
/usr/local/src/nginx-1.6.3
[root@Nginx10000 nginx-1.6.3]# ll
total 624
-rw-r--r--. 1 1001 1001 236608 Apr  7  2015 CHANGES
-rw-r--r--. 1 1001 1001 360501 Apr  7  2015 CHANGES.ru
-rw-r--r--. 1 1001 1001   1397 Apr  7  2015 LICENSE
-rw-r--r--. 1 1001 1001     49 Apr  7  2015 README
drwxr-xr-x. 6 1001 1001   4096 May 11 19:24 auto
drwxr-xr-x. 2 1001 1001   4096 May 11 19:24 conf
-rwxr-xr-x. 1 1001 1001   2369 Apr  7  2015 configure
drwxr-xr-x. 4 1001 1001   4096 May 11 19:24 contrib
drwxr-xr-x. 2 1001 1001   4096 May 11 19:24 html
drwxr-xr-x. 2 1001 1001   4096 May 11 19:24 man
drwxr-xr-x. 8 1001 1001   4096 May 11 19:24 src


添加 nginx 系統用戶

[root@Nginx10000 nginx-1.6.3]# useradd -r -s /sbin/nologin nginx
[root@Nginx10000 nginx-1.6.3]#


檢查編譯: configure 說明   

在編譯的時候 有任何的警告 都不要理它 只要不是提示錯誤 Error

./configure 

--prefix=/application/nginx-1.6.3        軟件安裝的路徑

--user=nginx                  以nginx用戶身份運行,如果不指定 默認是nobody

--group=nginx                 組信息

--with-http_ssl_module                https加密模塊

--with-http_stub_status_module           監控狀態模塊 

./configure \
--prefix=/application/nginx-1.6.3 \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module

[root@Nginx10000 nginx-1.6.3]# echo $?   //檢查一下 上次執行的結果 0 代表完全成功
0


開始安裝 make && make install

[root@Nginx10000 nginx-1.6.3]# 
[root@Nginx10000 nginx-1.6.3]# make && make install



創建一個軟鏈接

ln -s /application/nginx-1.6.3/ /application/nginx



到此爲止 安裝成功.................................



嘗試Nginx是否成功

[root@Nginx10000 /]# /application/nginx-1.6.3/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful


開始啓動Nginx服務器吧......

[root@Nginx10000 /]# /application/nginx-1.6.3/sbin/nginx
[root@Nginx10000 /]# 
[root@Nginx10000 /]# lsof -i:80
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   5789  root    6u  IPv4  21260      0t0  TCP *:http (LISTEN)
nginx   5790 nginx    6u  IPv4  21260      0t0  TCP *:http (LISTEN)


利用 curl 命令進行本地連接測試一下  完全OK....

[root@Nginx10000 /]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.6.3
Date: Wed, 11 May 2016 12:03:21 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Wed, 11 May 2016 11:47:37 GMT
Connection: keep-alive
ETag: "57331bd9-264"
Accept-Ranges: bytes

利用瀏覽器訪問一下吧  由於默認防火牆是打開狀態 所以先關閉 iptables 服務

[root@Nginx10000 /]# /etc/init.d/iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]


wKiom1cyr_uhSZfGAAI2O4dMTng638.jpg





查看某個軟件安裝情況

[root@Nginx10000 ~]# /application/nginx-1.6.3/sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) 
TLS SNI support enabled
configure arguments: --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章