1、系統環境
[root@crazy-acong ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@crazy-acong ~]# uname -a Linux crazy-acong 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux [root@crazy-acong ~]# ifconfig eth0 | grep "inet addr" | awk -F : '{print $2}'| awk '{print $1}' 192.168.1.106
2、安裝步驟
2.1 安裝基礎依賴包
- 安裝 pcre
- 安裝 openssl-devel
# pcre 安裝 # 安裝 pcre庫是為了使 nginx 支持具備 URI 重寫功能的 rewrite 模塊,如果不安裝 pcre 庫,則 nginx 無法使用 rewrite 模塊功能 [root@crazy-acong ~]# yum -y install pcre pcre-devel [root@crazy-acong ~]# rpm -qa pcre pcre-devel pcre-devel-7.8-7.el6.x86_64 pcre-7.8-7.el6.x86_64 # openssl-devel 安裝 # nginx 在使用HTTPS服務的時候要用到此模塊,如果不安裝 openssl 相關包,安裝 nginx 的過程中會報錯。openssl 系統默認已經安裝,只需要安裝 openssl-devel 即可 [root@crazy-acong ~]# yum -y install openssl-devel [root@crazy-acong ~]# rpm -qa openssl-devel openssl openssl-1.0.1e-48.el6_8.3.x86_64 openssl-devel-1.0.1e-48.el6_8.3.x86_64
2.2 安裝 nginx
# 創建軟件包存放目錄 [root@crazy-acong ~]# mkdir -p /data/tools [root@crazy-acong ~]# cd /data/tools/ # 下載 nginx 的穩定版本 1.10.3 [root@crazy-acong tools]# wget http://nginx.org/download/nginx-1.10.3.tar.gz # 創建 nginx 用戶 [root@crazy-acong tools]# useradd nginx -s /sbin/nologin -M [root@crazy-acong tools]# tar -zxf nginx-1.10.3.tar.gz [root@crazy-acong tools]# cd nginx-1.10.3 [root@crazy-acong nginx-1.10.3]# ./configure --user=nginx --group=nginx --prefix=/data/application/nginx-1.10.3 --with-http_stub_status_module --with-http_ssl_module [root@crazy-acong nginx-1.10.3]# make [root@crazy-acong nginx-1.10.3]# make install [root@crazy-acong nginx-1.10.3]# ln -s /data/application/nginx-1.10.3/ /etc/nginx [root@crazy-acong nginx-1.10.3]# ln -s /data/application/nginx-1.10.3/sbin/nginx /usr/local/sbin/ # 使用 nginx -V 可以查看編譯是的參數 [root@crazy-acong ~]# /etc/nginx/sbin/nginx -V nginx version: nginx/1.10.3 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/data/application/nginx-1.10.3/ --with-http_stub_status_module --with-http_ssl_module # 檢查配置文件語法,可以防止因配置錯誤導致網站重啟或重新加載配置等對用戶的影響 [root@crazy-acong nginx-1.10.3]# nginx -t nginx: the configuration file /data/application/nginx-1.10.3//conf/nginx.conf syntax is ok nginx: configuration file /data/application/nginx-1.10.3//conf/nginx.conf test is successful # 啟動 nginx 服務 [root@crazy-acong nginx-1.10.3]# nginx # 查看是否啟動成功 [root@crazy-acong nginx-1.10.3]# netstat -lnpt | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10334/nginx
