1、源碼包安裝之前,首頁安裝依賴包
yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
2、去nginx官網去下載穩定版安裝包
wget http://nginx.org/download/nginx-1.14.2.tar.gz
3、解壓縮
tar -zxvf nginx-1.14.2.tar.gz
3、編譯安裝
cd nginx-1.14.2
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
make && make install
4、nginx相關命令
/usr/local/nginx/sbin/nginx # 啟動
/usr/local/nginx/sbin/nginx -s stop #停止
/usr/local/nginx/sbin/nginx -s reload #重新加載配置
5、將nginx加入環境變量
vim /etc/profile
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin
6、檢測nginx安裝
nginx -v # 命令檢測
http://服務器ip # 網頁檢測
網頁檢測可能失敗,因為防火牆
7、關閉防火牆
systemctl start firewalld #啟動
systemctl stop firewalld #關閉
systemctl status firewalld #查看狀態
systemctl disable firewalld # 開機禁用
systemctl enable firewalld #開機啟用