记得在nginx.conf文件内留一个server配置 否则会重启不成功

进system的service文件中心

cd /usr/lib/systemd/system

touch nginx.service

nano nginx.service

写入


[Unit]

Description=nginx - high performance web server

After=nginx.service

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx

ExecReload=/usr/local/nginx/sbin/nginx -s reload

ExecStop=/usr/local/nginx/sbin/nginx -s quit

Execenable=/usr/local/nginx/sbin/nginx

[Install]

WantedBy=multi-user.target
注释

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx
(nginx 编译文件启动的目录)

ExecReload=/usr/local/nginx/sbin/nginx -s reload
(nginx 复制上面的)

ExecStop=/usr/local/nginx/sbin/nginxx -s stop
(nginx 复制上面的)

Execenable=/usr/local/nginx/sbin/nginx
(nginx 的sbin目录)

给目录授权 设置开机自启动

chmod 754 /usr/lib/systemd/system/nginx.service

systemctl enable nginx.service

systemctl start nginx.service

systemctl status nginx

nginx 配置ssl模块

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module 
--with-stream  --with-stream_ssl_module --with-stream_ssl_preread_module 

make && make install

输入 ./configure --help 查看帮助

最后修改日期: 2021年1月15日