安装httpd-2.4.46服务脚本

安装httpd-2.4.46服务脚本

#!/bin/bash
#
#********************************************************************
#Author:		llliuhuiii
#QQ: 			1694993508
#Date: 			2020-10-27
#FileName:		install_httpd.sh
#URL:           http://www.lianlianlianlian.cn
#Description:		The test script
#Copyright (C): 	2020 All rights reserved
#********************************************************************
target_dir=/usr/local/src
install_dir=/apps/httpd

#安装相关包
yum -y install wget gcc make pcre-devel openssl-devel expat-devel
rpm -q wget ||yum -y install wget
#下载源代码并解压缩
wget -P $target_dir  https://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz
wget -P $target_dir  https://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
wget -P $target_dir  https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.gz
cd $target_dir
tar xf  httpd-2.4.46.tar.gz
tar xf apr-1.7.0.tar.gz 
tar xf apr-util-1.6.1.tar.gz 
mv apr-1.7.0 httpd-2.4.46/srclib/apr
mv apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
cd httpd-2.4.46/
./configure --prefix=/apps/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre \
--with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
#创建apache用户
useradd -r -s /sbin/nologin apache
#修改配置文件
sed -i 's/^User.*/User apache/' ${install_dir}/conf/httpd.conf
sed -i 's/^Group.*/Group apache/' ${install_dir}/conf/httpd.conf

echo 'PATH="/apps/httpd/bin:$PATH"' > /etc/profile.d/httpd.sh
/etc/profile.d/httpd.sh
echo 'MANDATORY_MANPATH   /apps/httpd/man' >> /etc/man_db.conf
cat > /lib/systemd/system/httpd.service << EOF
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
ExecStart=/apps/httpd/bin/apachectl start
ExecReload=/apps/httpd/bin/apachectl graceful
ExecStop=/apps/httpd/bin/apachectl stop
# 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
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now httpd.service

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值