国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

詳解基于CentOS 7配置Nginx自啟動

2024-08-30 12:22:28
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了詳解基于CentOS 7配置Nginx自啟動,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

Nginx是廣為流行的輕量級Web服務器軟件。它開源,短小精悍,簡單易用,深受廣大互聯網企業以及IT運維人員所喜愛。很多時候,我們在生產環境基于編譯方式安裝Nginx后,Nginx需要手工配置自啟動服務,以確保服務器異常宕機后自動重啟該服務。以下描述的是基于CentOS 7下來配置自啟動服務,供大家參考。

一、yum 安裝方式Nginx自啟動

當前環境

[root@node142 ~]# more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 

查看是否保護nginx rpm包

[root@node142 ~]# rpm -qa|grep nginxnginx-mod-http-geoip-1.12.2-2.el7.x86_64nginx-1.12.2-2.el7.x86_64nginx-filesystem-1.12.2-2.el7.noarchnginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64nginx-mod-stream-1.12.2-2.el7.x86_64nginx-mod-http-perl-1.12.2-2.el7.x86_64nginx-mod-http-image-filter-1.12.2-2.el7.x86_64nginx-all-modules-1.12.2-2.el7.noarchnginx-mod-mail-1.12.2-2.el7.x86_64

查看是否存在相應的服務,如下,有nginx.service

[root@node142 ~]# systemctl list-unit-files |grep nginxnginx.service               disabled

將其配置為自動

[root@node142 ~]# systemctl enable nginx.service

查看nginx.service文件

[root@node142 ~]# more /lib/systemd/system/nginx.service[Unit]Description=The nginx HTTP and reverse proxy serverAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingPIDFile=/run/nginx.pid# Nginx will fail to start if /run/nginx.pid already exists but has the wrong# SELinux context. This might happen when running `nginx -t` from the cmdline.# https://bugzilla.redhat.com/show_bug.cgi?id=1268621ExecStartPre=/usr/bin/rm -f /run/nginx.pidExecStartPre=/usr/sbin/nginx -tExecStart=/usr/sbin/nginxExecReload=/bin/kill -s HUP $MAINPIDKillSignal=SIGQUITTimeoutStopSec=5KillMode=processPrivateTmp=true[Install]WantedBy=multi-user.target

上述配置文件中的內容和官網提供的一模一樣

https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

二、編譯安裝后的自啟動配置

由于是編譯安裝,因此,對于這個自啟動的腳本我們需要自行配制。

具體則是參考上面的鏈接或者上面給出的nginx.service文件內容。

然后將其保存為 /lib/systemd/system/nginx.service。

看下面的例子

# more /etc/redhat-release CentOS Linux release 7.4.1708 (Core) # ps -ef|grep nginxroot  10092 10014 0 16:23 pts/0  00:00:00 grep --color=auto nginxroot  20791  1 0 Mar20 ?    00:00:00 nginx: master process ./sbin/nginx -c /u01/app/nginx/nginx.confnobody 20792 20791 0 Mar20 ?    00:00:44 nginx: worker processnobody 20793 20791 0 Mar20 ?    00:00:42 nginx: worker processnobody 20794 20791 0 Mar20 ?    00:00:50 nginx: worker processnobody 20795 20791 0 Mar20 ?    00:00:44 nginx: worker processnobody 20796 20791 0 Mar20 ?    00:00:43 nginx: worker processnobody 20797 20791 0 Mar20 ?    00:00:43 nginx: worker processnobody 20798 20791 0 Mar20 ?    00:00:37 nginx: worker processnobody 20799 20791 0 Mar20 ?    00:00:48 nginx: worker processnobody 20800 20791 0 Mar20 ?    00:00:04 nginx: cache manager process# 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西平县| 铁岭县| 武定县| 宝应县| 乃东县| 长葛市| 曲靖市| 游戏| 嵊泗县| 乐东| 集安市| 远安县| 会东县| 岗巴县| 称多县| 聂荣县| 重庆市| 屏东县| 罗平县| 临汾市| 滨州市| 正定县| 丹凤县| 萍乡市| 舞阳县| 林芝县| 文化| 白城市| 宿迁市| 惠安县| 赫章县| 福贡县| 盘山县| 墨脱县| 耒阳市| 崇明县| 梓潼县| 贺兰县| 栖霞市| 马山县| 密云县|