一、安裝相關組件
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
二、下載安裝包
wget http://nginx.org/download/nginx-1.9.7.tar.gz
三、安裝Nginx
解壓縮:tar xf nginx-1.9.7.tar.gz && cd nginx-1.9.7
編譯: ./configure --prefix=/usr/local/nginx --with-http_gzip_module --with-http_stub_status_module --with-http-ssl_module --with-http_flv_module --with-http_rewrite_module && make && make install
四、配置環境變量
vim /etc/profile.d/nginx.sh
NGINX_HOME=/usr/local/nginx
PATH=$NGINX_HOME/sbin:$PATH
export PATH
source /etc/profile
五、測試訪問
啓動服務: nginx
檢查是否啓動: netstat -tlnp |grep 80
ps uax |grep nginx
lsof -i:80
測試: curl http://localhost
curl --head http://localhost
elinks http://localhost