编译安装httpd2.4.25并编写systemd脚本
发表于:2025-02-04 作者:千家信息网编辑
千家信息网最后更新 2025年02月04日,编译安装httpd2.4.25并编写systemd脚本一、官方的httpd安装脚本[root@textbox ~]# rpm -q --scripts httpdpreinstall scriptle
千家信息网最后更新 2025年02月04日编译安装httpd2.4.25并编写systemd脚本
编译安装httpd2.4.25并编写systemd脚本
一、官方的httpd安装脚本
[root@textbox ~]# rpm -q --scripts httpdpreinstall 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 || : fipreuninstall 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 || : fipostuninstall 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#Systemdposttrans 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 #当前unit应当晚于哪些unit启动Documentation=man:httpd(8) #man手册Documentation=man:apachectl(8) #man手册[Service]Type=notify #unit进程启动类型,notify为在启动完成后会发送一个通知消息。还需要配合 NotifyAccess 来让 Systemd 接收消息 EnvironmentFile=/etc/sysconfig/httpd #环境配置文件ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND #指明启动unit要运行命令或脚本的绝对路径 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful #指明reloadunit要运行的命令或脚本绝对路径ExecStop=/bin/kill -WINCH ${MAINPID} #指明停止unit要运行的命令或脚本# 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 #设置杀死进程的 第一步使用什么信号(见上文)SIGCONT是18号信号,表示继续PrivateTmp=true #启动服务时会在/tmp目录生成一个类似system-private-xxx的文件,存在临时文件[Install]WantedBy=multi-user.target #:被哪些units所依赖,弱依赖
三、一键安装脚本
参考:https://blog.51cto.com/14012942/2427694
四、最终自己写的system文件
[root@textbox ~]# cat /usr/lib/systemd/system/httpd.service [Unit]Description=The Apache HTTP ServerAfter=network.target remote-fs.target nss-lookup.target[Service]Type=simpleEnvironmentFile=/etc/httpd/httpd.confExecStart=/apps/httpd24/bin/apachectl -k start -DFOREGROUNDExecReload=/apps/httpd24/bin/apachectl -k gracefulExecStop=/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 -DFOREGROUNDSep 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...ssageHint: 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)
脚本
文件
命令
运行
信号
手册
消息
路径
进程
参考
编译
上文
信息
官方
效果
环境
目录
类型
部分
一键
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
深圳做硬件还是软件开发
超微服务器是哪的
数据库如何提高并发能力
数据库技术的主要数据模型
邮箱服务器安全配置端口
青浦区环保网络技术哪家强
复兴号网络安全车顶
电脑软件开发价位
中华人民共和国网络安全法指
医院网络安全自检自查表
西门子服务器突然开不了机了
做软件开发用苹果小号笔记本
想做软件开发办理什么执照
联百互联网络科技公司
智能安防网络技术应用
靠谱的中小企业erp软件开发
特别重大网络安全事件规定
陕西信合网络安全宣传
esxi服务器远程管理网卡
网络技术基础单元目标
nvdia显示无法连接服务器
阿里云香港服务器ip封了
英雄联盟服务器状态查询
连接oracle数据库慢
华西证券网络安全
广州一呼百应网络技术怎么样
asp显示多级分类数据库
李沧区分销软件开发产品
数据库技术用什么书
公司计划上市网络安全合规检查