系統版本
CentOS release 6.9 (Final)
2.6.32-696.el6.x86_64 x86_64
#安裝pcre pcre-devel
[root@web01 ~]# yum install pcre pcre-devel -y
#檢查pcre pcre-devel
[root@web01 ~]# rpm -qa pcre pcre-devel
pcre-7.8-7.el6.x86_64
pcre-devel-7.8-7.el6.x86_64
#安裝openssl-devel,使用nginx必須安裝這個軟件來支持
[root@web01 nginx-1.6.3]# yum install openssl-devel -y
#檢查openssl-devel openssl
[root@web01 nginx-1.6.3]# rpm -qa openssl-devel openssl #檢查openssl-devel openssl
openssl-1.0.1e-57.el6.x86_64
openssl-devel-1.0.1e-57.el6.x86_6
#添加用戶
useradd oldboy
#創建tools目錄
mkdir /home/oldboy/tools
cd /home/oldboy/tools/
#下載nginx,具體需要什麼版本自己可以到 http://nginx.org官網下載
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
#查看到下載的nginx
[root@web01 tools]# ll
總用量 788
-rw-r--r-- 1 root root 805253 4月 8 2015 nginx-1.6.3.tar.gz
#解壓壓縮包
[root@web01 tools]# tar xf nginx-1.6.3.tar.gz
#cd到nginx-1.6.3目錄下
cd nginx-1.6.3
#創建application目錄存放軟件
mkdir /application
#創建虛擬用戶
[root@web01 application]# useradd www -s /sbin/nologin -M
#編譯安裝nginx
./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/
#查看編輯是否成功
[root@web01 nginx-1.6.3]# echo $? #返回
0表示配置成功
0
[root@web01 nginx-1.6.3]# make #返回0直接就用make編譯
同樣是echo $?是返回0正常
#安裝
[root@web01 nginx-1.6.3]# make install
#安裝完成之後,爲了以後更新軟件方便,需要創建一個軟鏈接給nginx
[root@web01 nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx
[root@web01 nginx-1.6.3]# cd /application/
[root@web01 application]# ll
總用量 4
lrwxrwxrwx 1 root root 25 2月 27 11:13 nginx -> /application/nginx-1.6.3/
drwxr-xr-x 6 root root 4096 2月 27 11:12 nginx-1.6.3
#啓動nginx
[root@web01 application]# /application/nginx/sbin/nginx
[root@web01 ~]# /application/nginx/sbin/nginx -t #檢查語法對不對
1. 1. 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
[root@web01 application]# netstat -lntup |grep 80 #查看nginx端口是否啓動
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 45878/nginx
在自己瀏覽器查看是否成功
一鍵安裝命令如下:
[root@web01 scripts]# cat nginx.sh
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
LANG=en
yum install pcre pcre-devel -y
yum install openssl-devel -y
useradd oldboy
mkdir /home/oldboy/tools
cd /home/oldboy/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
mkdir /application
useradd www -s /sbin/nologin -M
./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/
echo $?
make
echo $?
make install
ln -s /application/nginx-1.6.3/ /application/nginx
cd /application/
/application/nginx/sbin/nginx
/application/nginx/sbin/nginx -t
netstat -lntup |grep 80