編譯安裝httpd2.4.25并編寫(xiě)systemd腳本-創(chuàng)新互聯(lián)

編譯安裝httpd2.4.25并編寫(xiě)systemd腳本

一、官方的httpd安裝腳本

專業(yè)從事做網(wǎng)站、成都網(wǎng)站建設(shè),高端網(wǎng)站制作設(shè)計(jì),成都微信小程序,網(wǎng)站推廣的成都做網(wǎng)站的公司。優(yōu)秀技術(shù)團(tuán)隊(duì)竭力真誠(chéng)服務(wù),采用HTML5建站+CSS3前端渲染技術(shù),成都響應(yīng)式網(wǎng)站建設(shè),讓網(wǎng)站在手機(jī)、平板、PC、微信下都能呈現(xiàn)。建站過(guò)程建立專項(xiàng)小組,與您實(shí)時(shí)在線互動(dòng),隨時(shí)提供解決方案,暢聊想法和感受。
[root@textbox ~]# rpm -q --scripts httpd
preinstall scriptlet (using /bin/sh):
# Add the "apache" group and user
/usr/sbin/groupadd -g 48 -r apache 2> /dev/null || :
/usr/sbin/useradd -c "Apache" -u 48 -g apache \
    -s /sbin/nologin -r -d /usr/share/httpd apache 2> /dev/null || :
postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        systemctl preset httpd.service htcacheclean.service >/dev/null 2>&1 || : 
fi
preuninstall scriptlet (using /bin/sh):

if [ $1 -eq 0 ] ; then 
        # Package removal, not upgrade 
        systemctl --no-reload disable httpd.service htcacheclean.service > /dev/null 2>&1 || : 
        systemctl stop httpd.service htcacheclean.service > /dev/null 2>&1 || : 
fi
postuninstall scriptlet (using /bin/sh):

systemctl daemon-reload >/dev/null 2>&1 || : 

# Trigger for conversion from SysV, per guidelines at:
# https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd
posttrans scriptlet (using /bin/sh):
test -f /etc/sysconfig/httpd-disable-posttrans || \
  /bin/systemctl try-restart httpd.service htcacheclean.service >/dev/null 2>&1 || :

二、httpd的systemd文件

參考:http://www.jinbuguo.com/systemd/systemd.kill.html

分為3部分:[Unit]、[Service]和[Install]

[root@textbox system]# cat httpd.service
[Unit]
Description=The Apache HTTP Server      #描述信息
After=network.target remote-fs.target nss-lookup.target     #當(dāng)前unit應(yīng)當(dāng)晚于哪些unit啟動(dòng)
Documentation=man:httpd(8)      #man手冊(cè)
Documentation=man:apachectl(8)  #man手冊(cè)

[Service]
Type=notify     #unit進(jìn)程啟動(dòng)類型,notify為在啟動(dòng)完成后會(huì)發(fā)送一個(gè)通知消息。還需要配合 NotifyAccess 來(lái)讓 Systemd 接收消息 
EnvironmentFile=/etc/sysconfig/httpd    #環(huán)境配置文件
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND #指明啟動(dòng)unit要運(yùn)行命令或腳本的絕對(duì)路徑 
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful #指明reloadunit要運(yùn)行的命令或腳本絕對(duì)路徑
ExecStop=/bin/kill -WINCH ${MAINPID}    #指明停止unit要運(yùn)行的命令或腳本
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT  #設(shè)置殺死進(jìn)程的 第一步使用什么信號(hào)(見(jiàn)上文)SIGCONT是18號(hào)信號(hào),表示繼續(xù)
PrivateTmp=true     #啟動(dòng)服務(wù)時(shí)會(huì)在/tmp目錄生成一個(gè)類似system-private-xxx的文件,存在臨時(shí)文件

[Install]
WantedBy=multi-user.target      #:被哪些units所依賴,弱依賴

三、一鍵安裝腳本

參考:https://blog.51cto.com/14012942/2427694

四、最終自己寫(xiě)的system文件

[root@textbox ~]# cat /usr/lib/systemd/system/httpd.service 
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
EnvironmentFile=/etc/httpd/httpd.conf
ExecStart=/apps/httpd24/bin/apachectl -k start  -DFOREGROUND
ExecReload=/apps/httpd24/bin/apachectl  -k graceful
ExecStop=/usr/bin/kill -WINCH ${MAINPID}
PrivateTmp=true

[Install]
WantedBy=multi-user.target

效果:

[root@textbox ~]# systemctl start httpd
[root@textbox ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-09-04 21:25:16 CST; 1min 51s ago
 Main PID: 35575 (apachectl)
   CGroup: /system.slice/httpd.service
           ├─35575 /bin/sh /apps/httpd24/bin/apachectl -k start -DFOREGROUND
           ├─35577 /apps/httpd24/bin/httpd -k start -DFOREGROUND
           ├─35593 /apps/httpd24/bin/httpd -k start -DFOREGROUND
           ├─35594 /apps/httpd24/bin/httpd -k start -DFOREGROUND
           └─35595 /apps/httpd24/bin/httpd -k start -DFOREGROUND

Sep 04 21:25:16 textbox systemd[1]: Started The Apache HTTP Server.
Sep 04 21:25:31 textbox apachectl[35575]: AH00558: httpd: Could not reliably determine the server's fully qual...ssage
Hint: Some lines were ellipsized, use -l to show in full.
[root@textbox ~]# systemctl stop httpd
[root@textbox ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁(yè)標(biāo)題:編譯安裝httpd2.4.25并編寫(xiě)systemd腳本-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://bm7419.com/article2/ijgic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、品牌網(wǎng)站建設(shè)、微信公眾號(hào)、移動(dòng)網(wǎng)站建設(shè)外貿(mào)網(wǎng)站建設(shè)、外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)