一键安装 httpd-2.4 脚本
注:此脚本适用于 centos7 及以上版本,具体需要根据实际情况进行测试调整
[root@centos7 ~]# vim install_httpd24.sh
#!/bin/bash
#
#**************************************************
#Author: Xan_Yum
#QQ: 7993167
#Email: waluna@qq.com
#Version: 1.0
#Date: 2021-06-03
#FileName: install_httpd24.sh
#Description: Install httpd
#URL: https://waluna.top
#Copyroght (C): 2021 ALL rights reserved
#**************************************************
. /etc/init.d/functions
echo "install packages"
yum install bzip2 gcc make pcre-devel openssl-devel expat-devel -y &> /dev/null && action "install complete"
echo "download apr-1.7.0.tar.bz2"
wget https://mirrors.bfsu.edu.cn/apache//apr/apr-1.7.0.tar.bz2 &> /dev/null && action "download complete"
echo "download apr-util-1.6.1.tar.bz2"
wget https://mirrors.bfsu.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2 &> /dev/null && action "download complete"
echo "download httpd-2.4.48.tar.bz2"
wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.48.tar.bz2 &> /dev/null && action "download complete"
echo "decompression apr-1.7.0.tar.bz2"
tar xf apr-1.7.0.tar.bz2 && action "Decompression complete"
echo "decompression apr-util-1.6.1.tar.bz2"
tar xf apr-util-1.6.1.tar.bz2 && action "Decompression complete"
echo "decompression httpd-2.4.48.tar.bz2"
tar xf httpd-2.4.48.tar.bz2 && action "Decompression complete"
[ ! -d "/apps" ] && mkdir /apps
mv apr-1.7.0 httpd-2.4.48/srclib/apr
mv apr-util-1.6.1 httpd-2.4.48/srclib/apr-util
cd httpd-2.4.48/
echo "begin compile"
./configure \
--prefix=/apps/httpd24 \
--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 &> /dev/null && action "compile complete"
echo "begin install"
make -j 8 &> /dev/null && make install &> /dev/null && action "install complete"
echo "create apache user"
id apache &> /dev/null || useradd -s /sbin/nologin -r apache && action "create complete"
echo "modify run user"
sed -i.bak 's/^User.*/User apache/' /apps/httpd24/conf/httpd.conf
sed -i 's/^Group.*/Group apache/' /apps/httpd24/conf/httpd.conf
echo "set PATH"
echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
. /etc/profile.d/httpd24.sh
echo "set man"
echo "MANDATORY_MANPATH /apps/httpd24/man" >> /etc/man_db.conf
echo "create service unit"
cat > /usr/lib/systemd/system/httpd24.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/httpd24/bin/apachectl start
ExecReload=/apps/httpd24/bin/apachectl graceful
ExecStop=/apps/httpd24/bin/apachectl stop
KillSignal=SIGWINCH
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now httpd24 &> /dev/null
ss -ntl|grep 80 &> /dev/null && action "service already start"
curl 127.0.0.1







Comments | NOTHING