centos7安装Nginx添加自启动

编译安装Nginx-1.16,安装在/usr/local/nginx

安装依赖

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc gcc-c++ make

配置安装模块

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

编译安装

make && make install
配置
cd /usr/lib/systemd/system
vim nginx.service
cat nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
输入 systemctl start nginx 启动
添加到开机启动: 输入 systemctl start nginx 启动
查看 此状态 输入 systemctl status nginx.service

原文链接: https://www.cnblogs.com/michael2018/p/12986400.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    centos7安装Nginx添加自启动

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/351571

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年3月2日 上午6:56
下一篇 2023年3月2日 上午6:57

相关推荐