綠色腳本
#!/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 &>/dev/null
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 success
fully!\033[0m" make install &>/dev/null
if [ $? -eq 0 ];then
echo -e "\033[32m make in
stall is complete!\033[0m" else
echo -e "\033[31m make in
satll is failed!\033[0m" fi
else
echo -e "\033[31m make is failed!
\033[0m" eixt
fi
else
echo -e "\033[31m config is failed!\033[0
m" 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[0
m" 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 serv
er is successfully!\033[0m" else
echo -e "\033[31m add system serv
er is failed!\033[0m" fi
else
echo -e "\033[31m sed acpachectl error!\0
33[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[0
m" else
echo -e "\033[31m The apache server up error!\033
[0m" exit
fi
fi
[root@localhost ~]# 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!
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/249456.html
標籤:其他
