使用Shell脚本一键部署Apache 服务

执行脚本之前将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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值