码迷,mamicode.com
首页 > Web开发 > 详细

一键部署apache

时间:2020-11-16 13:05:45      阅读:10      评论:0      收藏:0      [点我收藏+]

标签:c++   lib   httpd   script   编译   perl   list   pcr   config   

一键部署apache
#!/bin/bash
read -p "请输入httpd源码包所在绝对路径:" a
cd $a
echo "----开始安装----"
tar xjvf httpd-2.4.29.tar.bz2
tar xzvf apr-1.6.2.tar.gz
tar xzvf apr-util-1.6.0.tar.gz
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util

echo "----安装编译器和其它工具-----"
cd /var/run
rm -rf yum.pid
yum -y install gcc gcc-c++ make pcre-devel expat-devel perl

cd /opt/httpd-2.4.29/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

make
make install

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

sed -i ‘1a# chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭‘ /etc/init.d/httpd
sed -i ‘2a# description: Apache is a World Wide Web server‘ /etc/init.d/httpd

chkconfig --add httpd

b=$(ifconfig ens33 |tr -s ‘ ‘ : |cut -d: -f3 |sed -n ‘2p‘)
sed -i ‘51cListen ‘$b‘:80‘ /usr/local/httpd/conf/httpd.conf
sed -i ‘52s/^/#/‘ /usr/local/httpd/conf/httpd.conf

ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/

service httpd start > /dev/null

echo "apache服务已安装成功!"

一键部署apache

标签:c++   lib   httpd   script   编译   perl   list   pcr   config   

原文地址:https://blog.51cto.com/14625831/2547724

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!