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

關閉

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