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