CentOS7.8源码安装nginx

nginX:下载地址

 nginx反向代理访问:rethinkdb

编译安装即可

修改配置:vi /usr/local/nginx1.19/conf/nginx.conf

 

环境配置:vi /etc/profile

#nginx Env
export NGINX_HOME=/usr/local/nginx1.19
export PATH=${NGINX_HOME}/sbin:$PATH

检查配置:nginx -V

启动:./nginx
重载:./nginx -s reload
停止:./nginx -s stop

 

配置系统服务

进入目录 /usr/lib/systemd/system,新建文件 nginx.service,添加如下内容

[Unit]
Description=nginx
After=network.target remote-fs.target nss-lookup.target

#下边的路径换成本地实际的即可
[Service]
ExecStart=/usr/local/nginx1.19/sbin/nginx -c /usr/local/nginx1.19/conf/nginx.conf
ExecReload=/usr/local/nginx1.19/sbin/nginx -s reload -c /usr/local/nginx1.19/conf/nginx.conf
ExecStop=/usr/local/nginx1.19/sbin/nginx -s quit
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target
查看状态:systemctl status nginx
启动服务:systemctl start nginx
停止服务:systemctl stop nginx
重载服务:systemctl reload nginx
启用开机启动:systemctl enable nginx
关闭开机启动:systemctl disable ngixn

 

posted on 2021-03-13 16:05  GSY921  阅读(54)  评论(0编辑  收藏  举报

导航