#!/bin/bash
yum -y install wget
wget https://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz -P /root/
tar -zxf /root/httpd-2.4.25.tar.gz -C /usr/src/
yum -y install gcc gcc-* make
yum -y install apr-util-devel pcre-devel zlib-devel
echo "下载依赖完成"
cd /usr/src/httpd-2.4.25
echo "正在编译安装"
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
make && make install
echo "编译安装结果" $?
echo "优化执行路径"
ln -s /usr/local/httpd/bin/* /usr/local/bin
echo "添加系统服务"
cat > /lib/systemd/system/httpd.service << 'EOF'
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart= /usr/local/bin/apachectl $OPTIONS
ExecrReload= /bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
EOF
echo "开启httpd服务"
systemctl start httpd
echo "设置httpd服务开机自启动"
systemctl enable httpd
rm -rf /root/httpd-2.4.25.tar.gz
Apache 部署 (shell脚本)
最新推荐文章于 2024-08-20 15:47:40 发布