Nginx 1.28.0 安裝與配置流程
1. 下載與解壓
cd ~
wget http://nginx.org/download/nginx-1.28.0.tar.gz
tar -zxvf nginx-1.28.0.tar.gz
cd nginx-1.28.0
2. 配置編譯參數
./configure \--prefix=/home/ynnewweb/nginx \--with-http_ssl_module \--with-http_gzip_static_module \--with-http_stub_status_module \--with-http_realip_module \--with-stream \--with-stream_ssl_module \--with-pcre \--with-threads \--with-ipv6
3. 編譯并安裝
make
make install
4. 驗證安裝
/home/ynnewweb/nginx/sbin/nginx -v
/home/ynnewweb/nginx/sbin/nginx -t
5. 配置環境變量(永久生效)
編輯 ~/.bashrc
:
vim ~/.bashrc
在文件末尾添加:
export PATH=$PATH:/home/ynnewweb/nginx/sbin
使其立即生效:
source ~/.bashrc
6. 使用 nginx 命令
# 檢查配置文件是否正確
nginx -t# 啟動 Nginx
nginx# 平滑重載配置
nginx -s reload# 停止 Nginx
nginx -s stop