#!/bin/bash
Stack=$1
if [ "${Stack}" = "" ]; then
Stack="install"
else
Stack=$1
fi
install_httpd()
{
rpm -q httpd
read -p "The http access directory(default:/home): " directory
if [ "${directory}" != "" ]; then
directorys="${directory}"
else
directorys="/home"
fi
yum -y install httpd
if [ "$?" -eq "0" ]; then
if [ -d ${directorys} ]; then
chmod -R 705 ${directorys}
fi
firewall-cmd --permanent --add-service=http
firewall-cmd --list-all
firewall-cmd --reload
setenforce 0
mkdir /home/www
echo "The Web's DocumentRoot Test " > /home/www/myweb.html
echo "DocumentRoot "/home/www">">>httpd.conf
echo "<Directory "/home/www">">>httpd.conf
echo "AllowOverride None">>httpd.conf
echo "Require all granted">>httpd.conf
echo "</Directory>">>httpd.conf
chkconfig httpd on
service httpd restart
echo "The http directory:${directorys}"
else
echo "httpd installation failed!"
fi
}
case "${Stack}" in
install)
install_httpd
;;
*)
esac
如果对您有帮助,请点赞关注,谢谢!!!