手动编译安装和自动化脚本编译安装httpd-2.4.46

手动编译安装httpd-2.4.46:

#环境准备:
关闭selinux和防火墙
#安装相关包:
[root@centos8 ~]#yum -y install make gcc apr-devel apr-util-devel pcre-devel redhat-rpm-config openssl-devel bzip2
#下载并解压缩包:
[root@centos8 ~]#cd /usr/local/src
[root@centos8 src]#tar xvf httpd-2.4.43.tar.bz2
#配置:
[root@centos8 httpd-2.4.46]#cd httpd-2.4.43
[root@centos8 httpd-2.4.46]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
#编译并安装:
[root@centos8 httpd-2.4.46]#make -j 4
[root@centos8 httpd-2.4.46]#make intsall
#配置环境:
[root@centos8 httpd-2.4.46]# echo "PATH=/apps/httpd/bin:$PATH" > /etc/profile.d/httpd.sh
[root@centos8 httpd-2.4.46]# . /etc/profile.d/httpd.sh
[root@centos8 httpd-2.4.46]# sed -i 's/It works!/Welcome to my web!/' /apps/httpd/htdocs/index.html
#运行:
[root@centos8 httpd-2.4.46]# apachectl start
#指定用户apache运行
[root@centos8 httpd-2.4.46]#cd
[root@centos8 ~]#useradd -r -u 48 -s /sbin/nologin -d /var/www -c Apache apache
[root@centos8 ~]#vim /etc/httpd/httpd.conf
user apache
group apache
#配置生效和验证:
[root@centos8 ~]#apachectl restart
#用浏览器打开页面验证

脚本自动化实现编译安装httpd-2.4.46:

#!/bin/bash
DIR1=/usr/local/src
PACKAGE=httpd-2.4.46.tar.bz2
DIR2=httpd-2.4.46
DIR3=/apps/httpd
DIR4=/etc/httpd
echo -e "\e[1;$[RANDOM%7+31]mStarting compile install httpd-2.4.46\e[0m"
sleep 3
yum -y install make gcc apr-devel apr-util-devel pcre-devel redhat-rpm-config openssl-devel bzip2
cd $DIR1 
wget https://downloads.apache.org/httpd/httpd-2.4.46.tar.bz2
tar xvf $PACKAGE
cd $DIR2 
./configure --prefix="$DIR3" --sysconfdir="$DIR4" --enable-ssl
make -j 4 && make install
echo "PATH=${DIR3}/bin:$PATH" > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh
sed -i 's/It works!/Welcome to my web!/' /apps/httpd/htdocs/index.html
apachectl start &> /dev/null
cd
useradd -r -u 48 -s /sbin/nologin -d /var/www -c Apache apache
sed -i 's/User daemon/User apache/' /etc/httpd/httpd.conf 
sed -i 's/Group daemon/Group apache/' /etc/httpd/httpd.conf
apachectl restart &> /dev/null
echo -e "\e[1;$[RANDOM%7+31]mCompile install httpd-2.4.46 finished.\e[0m"
echo -e "\e[1;$[RANDOM%7+31]mPlease input ip access the web.\e[0m"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值