使用shell脚本自动安装Apache2.4.35
安装环境Centos7,联网进行安装。
脚本如下:
#!/bin/bash
[ $(id -u) != "0" ] && echo "error,not root user" && exit 1
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/bin:/usr/sbin
which httpd
if [ $? -eq 0 ];then
yum remove 'yum list installed | grep httpd' -y
#移除httpd 在已经安装的软件中搜索httpd 然后卸载
exit 1
fi
if [ ! -d /opt ];then
#检查是/opt是否为目录,不是则创建并进入,是则进入
mkdir /opt && cd /opt
else
cd /opt
fi
echo "是否下载apache(y/n)"
read -p "请输入y/n" cho
case $cho in
y)
echo "正在下载Apache"
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.35.tar.bz2
wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.5.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
a=httpd-2.4.35
b=apr-1.6.5
c=apr-util-1.6.1
;;
n)
echo "退出下载"
exit 0
;;
*)
echo "错误退出请输入(y/n)"
;;
esac
if [ $? -eq 0 ];then
tar xjf $a.tar.bz2
tar zxf $b.tar.gz
tar zxf $c.tar.gz
else
echo "下载错误"
exit 1
fi
cp -R $b /opt/$a/srclib/apr
cp -R $c /opt/$a/srclib/apr-util
yum install gcc gcc-c++ pcre pcre-devel zlib-devel expat-devel -y
cd /opt/$a
./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--disable-cgi
make && make install
grep -v "#" /usr/local/httpd/bin/apachectl > /etc/init.d/httpd
sed -i '1i # description:Apache is a World Wide Web server.' /etc/init.d/httpd
sed -i '1i # chkconfig:2345 85 15' /etc/init.d/httpd
sed -i '1i #!/bin/sh' /etc/init.d/httpd
chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 35 httpd on
ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
新手上路,请大家多多指点。
- shell脚本:LAMP一键自动安装 (linux,apache,mysql,php)
- CentOS6.7下使用非root用户(普通用户)编译安装与配置mysql数据库并使用shell脚本定时任务方式实现mysql数据库服务随机自动启动
- 使用shell脚本一键安装zabbix并配置客户端的自动发现选项
- 自动安装多个tomcat shell脚本
- RPM包安装mysql,采用shell脚本实现自动安装、配置与卸载
- 一个检查并自动安装oralce所需rpm的shell脚本
- suse linux luckemftp安装及ftp shell自动上传脚本
- shell脚本实现linux下自动安装Oracle10g
- Shell小脚本:实现自动安装Asterisk和DAHDI
- 【Shell脚本】自动ssh登录重启Apache
- 自动安装jdk shell脚本
- Linux中使用Msmtp+mutt+shell自动发邮件程序安装说明
- 使用Shell脚本实现ftp的自动上传下载
- shell脚本实现linux下自动安装Oracle10g
- 一个检查并自动安装oralce所需rpm的shell脚本
- apache自动安装的小脚本
- linux APACHE2.2.10源码安装服务自动启动脚本
- web自动安装脚本(apache/nginx+php+mysql)
- 一个检查并自动安装oralce所需rpm的shell脚本
- shell脚本实现DNS的自动安装与配置