1.1.1 编译安装nginx cd /usr/local/src/ wget https://nginx.org/download/nginx-1.18.0.tar.gz
安装依赖软件
yum install gcc pcre-devel openssl-devel zlib-devel -y
添加nginx用户组
useradd -M -s /sbin/nologin nginx
解压nginx安装包
tar xf nginx-1.18.0.tar.gz cd nginx-1.18.0/
编译安装
./configure --prefix=/usr/local/nginx
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_stub_status_module
--with-stream
make && make install
1.1.2 编辑启动脚本,使用systemctl管理nginx vim /usr/lib/systemd/system/nginx.service [Unit] Description=nginx After=network.target [Service] Type=forking ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop [Install] WantedBy=multi-user.target
加载
systemctl daemon-reload
启动nginx
systemctl start nginx