Shell脚本部署httpd服务

这个脚本展示了如何使用bash shell自动化部署httpd服务,并创建一个新用户。它涉及到了设置用户、安装httpd、配置文件修改、启用服务、调整权限以及提示用户设置个人主页登录密码。
摘要由CSDN通过智能技术生成

脚本内容

#!/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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值