码迷,mamicode.com
首页 > 其他好文 > 详细

centos7安装Nginx添加自启动

时间:2020-05-29 12:08:08      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:pen   ecs   server   des   gcc   user   openssl   esc   安装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

centos7安装Nginx添加自启动

标签:pen   ecs   server   des   gcc   user   openssl   esc   安装nginx   

原文地址:https://www.cnblogs.com/michael2018/p/12986400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!