HTTP编译在线编译安装

HTTP编译安装

定义了很多变量,新手直接拉出去跑,生产使用请自己修改变量和修改多余的信息,
因为自己需要bash -x 测试脚本所以该省略的没省略
写代码只是爱好,且行且珍惜

#!/bin/bash
# **********************************************************
# * Author : liujinxin
# * Email : 942207953@qq.com
# * Create time : 2021-05-28 07:44
# * Filename : htppd_Compile.sh
# * Description : 
# **********************************************************
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
. /etc/init.d/functions
HTTPD_URL=https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/
HTTPD_VERSION=httpd-2.4.46
apr_util_VERSION=apr-util-1.6.1
apr_VERSION=apr-1.7.0
apr_URL=https://downloads.apache.org/apr/
Unzip=/usr/local/src/
Install_dir=/apps/httpd


action "正在安装依赖包....."
yum -y install wget gcc make pcre-devel openssl-devel expat-devel
rpm -qi wget | yum install -qy wget

[ -d $Unzip  ] && mkdir $Unzip 
      wget -P $Unzip  $apr_URL$apr_VERSION.tar.gz
      wget -P $Unzip  $apr_URL$apr_util_VERSION.tar.gz
      wget -P $Unzip  $HTTPD_URL$HTTPD_VERSION.tar.gz
      cd $Unzip 
      tar xf apr-1.7.0.tar.gz
      tar xf apr-util-1.6.1.tar.gz
      tar xf httpd-2.4.46.tar.gz

cd $Unzip 
mv $apr_VERSION $HTTPD_VERSION/srclib/apr
mv $apr_util_VERSION $HTTPD_VERSION/srclib/apr-util
cd $HTTPD_VERSION/
./configure --prefix=$Install_dir --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 &> /dev/null
# 创建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="$Install_dir/bin:$PATH"' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh
# 配置man帮助

echo 'MANDATORY_MANPATH $Install_dir/man' >> /etc/man_db.conf
# 创建service unit文件,设置开机启动


cat > /lib/systemd/system/httpd.service << EOF
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=$Install_dir/bin/apachectl start
ExecReload=$Install_dir/bin/apachectl graceful
ExecStop=$Install_dir/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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值