执行脚本之前将Apache 所需的三个软件包上传到/opt 目录下
链接:Apache所需软件包下载链接
提取码:a4zr
#!/bin/bash
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
df | grep “sr0”
if [ $? -eq 0 ];then
yum -y install gcc gcc-c++ make pcre pcre-devel expat-devel perl &>/dev/null
else
mount /dev/sr0 /mnt
yum -y install gcc gcc-c++ make pcre pcre-devel expat-devel perl &>/dev/null
fi
read -p “请输入Apache源码包所在绝对路径:” a
cd $a
echo “----开始配置软件模块----”
tar zxvf apr-1.6.2.tar.gz &>/dev/null
tar zxvf apr-util-1.6.0.tar.gz &>/dev/null
tar jxvf httpd-2.4.29.tar.bz2 &>/dev/null
mv /opt/apr-1.6.2 /opt/httpd-2.4.29/srclib/apr
mv /opt/apr-util-1.6.0 /opt/httpd-2.4.29/srclib/apr-util
cd /opt/httpd-2.4.29/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
make
make install
ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
ln -s /usr/local/httpd/bin/* /usr/local/bin/
cd /lib/systemd/system
touch httpd.service
echo “[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
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target” >/lib/systemd/system/httpd.service
systemctl start httpd.service
systemctl enable httpd.service
b=$(sed -n ‘/IPADDR/p’ /etc/sysconfig/network-scripts/ifcfg-ens33 | awk -F “=” ‘{print $2}’)
sed -i ‘s/Listen 80/Listen $b:80/g’ /etc/httpd.conf
sed -i ‘s/#ServerName www.example.com:80/ServerName www.benet.com:80/g’ /etc/httpd.conf
systemctl restart httpd.service
echo “$b www.benet.com” >> /etc/hosts
echo “apache服务已安装成功!”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
点赞 5
评论 7
分享
收藏 9
打赏
举报
关注
一键三连
点赞Mark关注该博主, 随时了解TA的最新博文
使用Shell脚本一键部署Hadoop
Niclas的博客
4121
测试环境 Linux系统版本:CentOS 7 实现功能 1、Java环境一键配置 2、Hadoop单机版一键安装 3、Hadoo