马哥博客作业第4周

 
########AUTO_INSTALL_HTTPD-2.4.43####################
 
 
#!/bin/bash
#判断本机是否安装httpd
rpm -qa | grep httpd 
echo $?
$? -eq 0 ] $$ echo "httpd is exirts" || echo "httpd is not exirts"
#关闭防火墙
systemctl stop firewalld
#禁止防火墙开机启动
systemctl disable firewalld
#修改selinux
sed -i '/SELINUX=disabled/s/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#安装各种常用包
yum -y install gcc make openssl-devel redhat-rpm-config apr-devel apr-util-devel pcre-devel
#下载httpd包文件
wget https://downloads.apache.org//httpd/httpd-2.4.43.tar.bz2 
#解压包到指定路径下
tar xvf httpd-2.4.43.tar.bz2 -C /usr/local/src
#进入解压文件所在的文件夹
cd /usr/local/src/httpd-2.4.43/
#运行configure脚本,生成Makefile文件
./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
#编译
make -j 2
#编译安装
make install
#修改PATH变量,默认无法运行
echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
. /etc/profile.d/httpd24.sh
#启动服务
apachectl
#指定用apache用户运行
useradd -r -d /var/www  -c Apache -s /sbin/nologin -u 48 apache
sed -i -e '/User daemon/s/User daemon/User apache/g' -e '/Group daemon/s/Group daemon/Group apache/g' /etc/httpd24/httpd.conf
#重启服务
apachectl restart
#验证结果
ps aux



猜你喜欢

转载自www.cnblogs.com/luyinghui/p/12686338.html