脚本内容
#!/bin/bash
iptables -F
setenforce 0
read -p "输入创建的用户名:" user
useradd $user
#此用户的密码为123456
echo "123456" |passwd --stdin $user
yum -y install httpd
systemctl start httpd
systemctl enable httpd
mkdir /home/$user/public_html
echo "The New Web Directory" > /home/$user/index.html
sed -i.bak 's#/var/www/html#/home/'$user'#g' /etc/httpd/conf/httpd.conf
sed -Ei 's#<Directory "/var/www">#<Directory "/home/'$user'">#g' /etc/httpd/conf/httpd.conf
chmod -Rf 755 /home/$user
systemctl restart httpd
echo "正在切换selinux状态为enforcing"
sleep 2
sed -i.bak 's/SELINUX=disabled/SELINUX=enforcing/g' /etc/selinux/config
echo "切换完成!"
sed -i.bak 's/UserDir disabled/#UserDir disabled/g' /etc/httpd/conf.d/userdir.conf
sed -i 's/#Us