一键安装apache2.2.34

安装环境:centos6.5  部分依赖包已提前安装。

yum install -y apr-devel \
apr-util-devel \
openssl-devel \
libevent-devel \
pcre-devel

源码包目录:/usr/local/src/

安装目录:/usr/local/apache2

因为script里有用到相对目录的操作,所以不能用bash或者 ./ 执行,因为这两种方式会切换到子shell环境,提示找不到路径。

需要这样执行或者将脚本路径全部换成真实路径。

# source  auto_install_apache.sh

 

#!/bin/bash
#centos6.5
#2.6.32-431.el6.x86_64
#auto install httpd to /usr/local/apache2
#by sunny 2015

yum install -y \
zlib-devel \
openssl-devel

#path
prefix=/usr/local/apache2
file=httpd-2.2.34.tar.gz
filedir=httpd-2.2.34
hurl=http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/

#download apache
cd /usr/local/src/
wget -c $hurl$file
if [ $? -eq 0 ];then
    tar -zxvf $file &&cd $filedir
fi

#configure ; install
if [ "$PWD" = "/usr/local/src/$filedir" ];then
./configure \
--prefix=$prefix \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-ssl \
--enable-rewrite \
--enable-modules=most \
--enable-so

    if [ $? -eq 0 ];then
        make &&make install
        echo -e "\033[32m apache install successful...\033[0m"
        echo -e "\033[32m apache install dir:$prefix \033[0m"

    else
        echo -e "\033[32m error,please check the configure..\033[0m"
    fi
else
echo -e "\033[32m error,please check..\033[0m"
fi

  

 本脚本只安装,接下来配置服务

cp /usr/local/apache2/bin/apachectl  /etc/rc.d/init.d/httpd

 如果需要httpd开机启动

[root@localhost data]# chkconfig --add httpd
[root@localhost data]# chkconfig httpd on
[root@localhost data]# chkconfig --list|grep httpd
httpd          	0:off	1:off	2:on	3:on	4:on	5:on	6:off

可能chkconfig  --add会报错,编辑 /etc/init.d/httpd,加上两行内容即可

#chkconfig:235 61 61
#description:apache

 

转载于:https://www.cnblogs.com/sunny18/p/8250610.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值