- date
- # 判断光盘是否挂载
- df -h | grep /mnt>/dev/null
- if [$? -ne 0]
- then
- mount /dev/sr0 /mnt>/dev/null
- fi
- # 创建 yum 仓库
- rm -rf /etc/yum.repos.d/*
- echo -e "[a]\nname=test\nbaseurl=file:///mnt\nenabled=1\ngpgcheck=0">/etc/yum.repos.d/a.repo
- yum -y install gcc gcc-c++ expat-devel make pcre-devel &>/dev/null
- tar xzvf /root/pcre-8.41.tar.gz -C /opt &>/dev/null
- tar xjvf /root/apr-1.6.3.tar.bz2 -C /opt &>/dev/null
- tar xjvf /root/apr-util-1.6.1.tar.bz2 -C /opt &>/dev/null
- tar xjvf /root/httpd-2.4.29.tar.bz2 -C /opt &>/dev/null
- cd /opt
- mv apr-1.6.3/ httpd-2.4.29/srclib/apr
- mv apr-util-1.6.1/ httpd-2.4.29/srclib/apr-util
- mv pcre-8.41/ httpd-2.4.29/srclib/pcre
- # 进入到 apache 目录进行配置, 编译安装
- cd httpd-2.4.29/
- ./configure --prefix=/usr/local/httpd --enable-rewrite --enable-mods-shared=most --with-mpm=worker --enable-charset-lite --enable-so --enable-cgi
- make && make install &>/dev/null
- # 优化执行路径, 加入 httpd 到系统服务
- grep -v "#" /usr/local/httpd/bin/apachectl>/etc/init.d/httpd
- sed -i '1i #!/bin/bash\n#chkconfig:2345 80 40\n#description:apache is a web server' /etc/init.d/httpd
- chkconfig --add httpd
- chkconfig httpd on
- ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
- # 监听地址根据实际情况进行更改
- sed -i '51c Listen 192.168.30.15:80' /etc/httpd.conf
- sed -i '52c #Listen :80' /etc/httpd.conf
- service httpd start
- service iptables stop
- setenforce 0
- date
- echo "apache 已经安装完成"
来源: http://www.bubuko.com/infodetail-2725835.html