1、安装依赖
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
yum -y install gcc
2、编译并安装通用模块
./configure --with-http_ssl_module
make && make install
3、设置开机启动
#在/usr/lib/systemd/system 目录下创建此脚本
[root@localhost ~]# vim /usr/lib/systemd/system/nginx.service
[root@localhost ~]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#启动nginx
systemctl start nginx
#停止nginx
systemctl stop nginx
#重启nginx
systemctl restart nginx
#重新加载配置文件
systemctl reload nginx
如果报错
如果出现报错内容"Failed to execute operation: Access denied",输入"systemctl daemon-reexec"即可解决。