httpd简单源码安装

#!/bin/bash

centos_install(){
CPUS=`grep -c process /proc/cpuinfo`
HTTPD_VERSION=2.4.54
INSTALL_DIR=/apps/httpd

yum -y install apr-devel apr-util-devel pcre-devel  redhat-rpm-config  gcc make openssl-devel wget && echo "所需插件安装成功"
sleep 5
cd /usr/local/src
wget https://dlcdn.apache.org/httpd/httpd-${HTTPD_VERSION}.tar.gz  --no-check-certificat && echo "get success "|| { echo "httpd is not get" ;exit 100 ;}
tar xf httpd-${HTTPD_VERSION}.tar.gz
cd httpd-${HTTPD_VERSION}
./configure --prefix=${INSTALL_DIR} --sysconfdir=${INSTALL_DIR}/etc/  && echo "配置成功"
sleep 5
make -j $CPUS && make install 
[ $? -eq 0 ] && echo "编译成功,正在启动服务..." || echo "编译失败"
sleep 3
ln -s /apps/httpd/bin/apachectl /usr/local/bin/
sed -i 's/#ServerName www.example.com:80/ServerName www.example.com:80/' ${INSTALL_DIR}/etc/httpd.conf
cat > ${INSTALL_DIR}/htdocs/index.html << EOF
<html><body><h1>welcome to wang haha</h1></body></html>
EOF
apachectl start && echo "启动成功,请访问`hostname -I`"
}


ubuntu_install(){
CPUS=`grep -c process /proc/cpuinfo`
HTTPD_VERSION=2.4.54
INSTALL_DIR=/apps/httpd

apt -y install apr-devel apr-util-devel pcre-devel  redhat-rpm-config  gcc make openssl-devel wget 

cd /usr/local/src
wget https://dlcdn.apache.org/httpd/httpd-${HTTPD_VERSION}.tar.gz  --no-check-certificat || { echo "httpd is not get" ;exit 100 ;}
tar xf httpd-${HTTPD_VERSION}.tar.gz
cd httpd-${HTTPD_VERSION}
./configure --prefix=${INSTALL_DIR} --sysconfdir=${INSTALL_DIR}/etc/
make -j $CPUS && make install
ln -s /apps/httpd/bin/apachectl /usr/local/bin/
sed -i 's/#ServerName www.example.com:80/ServerName www.example.com:80/' ${INSTALL_DIR}/etc/httpd.conf
cat > ${INSTALL_DIR}/htdocs/index.html << EOF
<html><body><h1>welcome to wang haha</h1></body></html>
EOF
apachectl start && echo "安装成功,请访问`hostname -I`"

} 

. /etc/os-release
case $ID in
	centos)
	centos_install
	;;
        ubuntu)
	ubuntu_install
	;;
        *)
	echo "其他版本,未写安装脚本" 
	;;
esac

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值