apache一键安装脚本

近期在玩apache,首先安装apace要配置apr。apr-util,pcre,而配置这些基本都是千篇一律。所谓程序猿的精神就是降低反复性的劳动,以下请看我写的apache安装脚本:
这个脚本我也放到我的github上

#!/bin/bash
# 须要sudo运行

dir=`pwd`

#要安装pcre先要安装 g++
if [[ `ls /etc|grep redhat-release` != "" ]]
then
    yum -y install gcc gcc-c++
elif [[ `ls /etc|grep debian_version` != "" ]]
then
    apt-get -y install gcc gcc-c++
fi

if [[ `ls|grep apr` == "" ]]
then
    wget http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz
fi
tar -zxvf apr-1.5.2.tar.gz
mkdir /usr/local/lib/apr-1.5.2
cd $dir/apr-1.5.2
./configure --prefix=/usr/local/lib/apr-1.5.2 
make
make install

cd $dir
if [[ `ls|grep apr-util` == "" ]]
then
    wget http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz
fi
tar -zxvf apr-util-1.5.4.tar.gz
mkdir /usr/local/lib/apr-util-1.5.4.tar.gz
cd $dir/apr-util-1.5.4
./configure --prefix=/usr/local/lib/apr-util-1.5.4 --with-apr=/usr/local/lib/apr-1.5.2
make 
make install

cd $dir
if [[ `ls|grep pcre` == "" ]]
then
    wget http://ncu.dl.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
fi
tar -zxvf pcre-8.37.tar.gz
mkdir /usr/local/lib/pcre-8.37
cd $dir/pcre-8.37
./configure --prefix=/usr/local/lib/pcre-8.37
make 
make install

cd $dir
if [[ `ls|grep httpd` == "" ]]
then
    wget http://www.apache.org/dist/httpd/httpd-2.4.12.tar.gz
fi
tar -zxvf httpd-2.4.12.tar.gz
mkdir /usr/local/lib/httpd-2.4.12
cd $dir/httpd-2.4.12
./configure --prefix=/usr/local/lib/httpd-2.4.12 --with-apr=/usr/local/lib/apr-1.5.2  --with-apr-util=/usr/local/lib/apr-util-1.5.4 --with-pcre=/usr/local/lib/pcre-8.37  --enable-so
make
make install

#解决httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

sed -i 's/^#ServerName www.example.com:80/ServerName localhost/g' /usr/local/lib/httpd-2.4.12/conf/httpd.conf

/usr/local/lib/httpd-2.4.12/bin/apachectl start                          #启动apache
if [[ `curl -s localhost:80|grep "It works"` != "" ]]
then
    echo "----------------------成功安装-------------------------------------"
    cd $dir
    rm -rf apr-1.5.2/ apr-util-1.5.4/ pcre-8.37/ httpd-2.4.12/
fi

转载于:https://www.cnblogs.com/blfshiye/p/5101731.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值