apache安装脚本

绿色脚本

#!/bin/bash
apache=httpd-2.4.41.tar.gz
path=/usr/local/httpd
config="--prefix=$path --enable-so --enable-rewrite --enable-char
set-lite --enable-cgi"rpm  -e  httpd  --nodeps"

yum -y install gcc* apr* pcre* cyrus-sasl-devel expat-devel libdb
-devel openldap-devel &>/dev/null
if [ -e $apache ];then
	echo -e "\033[32m The httpd package install successfully!\033[0m"	
	tar -zxf $apache -C /root 
	if [ $? -eq 0 ];then
		echo -e "\033[32m unzip is complete!\033[0m"
		cd httpd-2.4.41
		./configure $config &>/dev/null
		if [ $? -eq 0 ];then
			echo -e "\033[32m config is complete!\033[0m"			
			make &>/dev/null
			if [ $? -eq 0 ];then
				echo -e "\033[32m make is successfully!\033[0m"	            					                                      
				make install &>/dev/null
				if [ $? -eq 0 ];then
					echo -e "\033[32m make install is complete!\033[0m"				
					else
					echo -e "\033[31m make insatll is failed!\033[0m"				
					exit
				fi
			else
				echo -e "\033[31m make is failed!\033[0m"				
				eixt
			fi
		else
			echo -e "\033[31m config is failed!\033[0m"			
			exit
		fi	
	else
		echo -e "\033[31m unzip is error!\033[0m"
		exit
	fi
else
	echo -e "\033[31m The httpd package is not exists! \033[0m"	
	exit
fi

if [ -e $path/bin ];then
	cp $path/bin/apachectl /etc/init.d/httpd &>/dev/null
	if [ $? -eq 0 ];then
		sed -i '3i#chkconfig:35 85 21\n#description:startup script for the apache httpd servier' /etc/init.d/httpd &>/dev/null		
		if [ $? -eq 0 ];then
			chkconfig --add httpd
			if [ $? -eq 0 ];then
				echo -e "\033[32m add system server is successfully!\033[0m" 
				else
				echo -e "\033[31m add system server is failed!\033[0m"	
				exit		
			fi
		else
			echo -e "\033[31m sed acpachectl error!\033[0m"			
			exit
		fi
	else
		echo -e "\033[31m cp acpachectl error!\033[0m"
		exit
	fi
else
	echo -e "\033[31m The $path is not exists!\033[0m"
	exit
fi

systemctl start httpd &>/dev/null
if [ $? -eq 0 ];then
	echo -e "\033[32m The apache server is run!\033[0m"
else
	systemctl restart httpd &>/dev/null
	if [ $? -eq 0 ];then
		echo -e "\033[32m The apache server is run!\033[0m"	
		else
		echo -e "\033[31m The apache server up error!\033[0m"		
		exit
	fi
fi
[root@haha ~]# sh apache.sh 
The httpd package install successfully!
Unzip is complete!
Config is complete!
Make is successfully!
Make install is complete!
Add system server is successfully!
The apache server is run!
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值