1.下载安装包
wget http://nginx.org/download/nginx-1.18.0.tar.gz
2.解压安装包
tar -zxvf nginx-1.18.0.tar.gz
3.移动到指定目录
mv nginx-1.18.0 /usr/local/nginx
4.安装编译插件
yum install -y pcre pcre-devel openssl openssl-devel gcc gcc gcc-c++ ncurses-devel perl
5.切换目录
cd /usr/local/nginx
6.编译配置
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
7.执行编译
make
8.编译安装
make install
9.创建www用户
/usr/sbin/groupadd -f www
/usr/sbin/useradd -g www www
10.创建软链接
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
11.启动nginx
nginx -c /usr/local/nginx/conf/nginx.conf
12.常用命令
(1) 重载配置文件
nginx -s reload
(2) 重启nginx
nginx -s reopen
(3) 停止nginx
nginx -s stop