操作系統(tǒng):CentOS 6.9
nginx版本:1.14.0
1. 安裝依賴環(huán)境
1.1 安裝gcc
yum install gcc-c++
1.2 安裝其他依賴
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
2. 下載安裝nginx
2.1 下載并解壓nginx安裝包
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar –zxvf nginx-1.14.0.tar.gz –C /usr/local
2.2 編譯安裝
進(jìn)入nginx-1.14.0的目錄,然后執(zhí)行./configure命令
# --prefix可以指定安裝目錄
./configure --prefix=/usr/local/nginx
make & make install
3. 啟動(dòng)及測(cè)試
3.1 啟動(dòng)nginx
/usr/local/nginx/sbin/nginx
# 啟動(dòng)完畢查看是否啟動(dòng)成功
ps -ef | grep nginx
# 效果
root 19945 1 0 Apr23 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www 19946 19945 0 Apr23 ? 00:00:00 nginx: worker process
www 19947 19945 0 Apr23 ? 00:00:00 nginx: worker process
root 20859 20835 0 09:46 pts/0 00:00:00 grep --color=auto nginx
如果要關(guān)閉nginx
/usr/local/nginx/sbin/nginx -s stop
重新熱啟動(dòng)nginx
/usr/local/nginx/sbin/nginx -s reload
3.2 測(cè)試nginx歡迎頁(yè)面
在地址欄輸入http://ip或者http://ip:80通過(guò)瀏覽器訪問(wèn)nginx歡迎頁(yè)膊夹,如下圖所示