Nginx--Systemd管理方式

Systemd

是一个系统管理守护进程、工具和库的集合,用于取代System V初始进程

Systemd的功能是用于集中管理和配置类UNIX系统

Systemctl

是一个Systemd工具,主要负责控制systemd系统和服务管理器

Nginx管理服务

/usr/local/nginx/sbin/nginx

开启

/usr/local/nginx/sbin/nginx -s stop

关闭

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

加载

我们可以使用 systenmctl 命令来控制 nginx

Systemd 管理 Nginx 服务

环境搭建

yum install gcc opensll-devel zlib-devel -y

yum install -y pcre-*

tar zxf nginx-*.tar.gz

cd /root/Desktop/nginx-*

mkdir ~/.vim

建立一个家目录下的隐藏目录

cp -r contrib/vim/* ~/.vim

让这个虚拟机的vim可以自动检测配置文件语法是否有错误

vim /root/Desktop/nginx-*/auto/cc/gcc

注释debug

172 CFLAGS="$CFLAGS -g"

vim /root/Desktop/nginx-*/src/core/nginx.h

关闭版本显示

防止恶意攻击

14 #define NGINX_VER "nginx/" NGINX_VERSION

删除 NGINX_VERSION

cd /root/Desktop/nginx-*

./configure --prefix=/usr/local/nginx --with-file-aio
编译
make && make install
安装

yum install -y httpd

安装 http

具体流程

httpd 启动脚本会在 /usr/lib/systemd/system 目录下

将httpd 的启动脚本复制给 nginx (系统自定义的启动脚本在 /etc/systemd/system/ 目录下)

cp /usr/lib/systemd/system/httpd.service

/etc/systemd/system/nginx.service

vim /etc/systemd/system/nginx.service

在这里插入图片描述

systemctl start nginx

开启

systemctl status nginx

查看状态

systemctl restart nginx

加载

systemctl stop nginx

关闭

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章