#添加包含虚拟主机
grep 'Include conf/extra/httpd-vhosts.conf' $install_dir/conf/httpd.conf &> /dev/null
if [ $? -eq 0 ];then
echo "Include conf/extra/httpd-vhosts.conf" >> $install_dir/conf/httpd.conf
fi
#配置虚拟主机
cat > $install_dir/conf/extra/httpd-vhosts.conf <<EOF
<VirtualHost *:80>
DocumentRoot "$install_dir/htdocs/zhuawawa.example.com"
ServerName zhuawawa.example.com
ErrorLog "logs/zhuawawa.example.com-error_log"
CustomLog "logs/zhuawawa.example.com-access_log" common
</VirtualHost>
EOF
#添加防火墙规则
firewall-cmd --add-rich-rule 'rule family=ipv4 source address=0.0.0.0/0 port port=80 protocol=tcp accept' --permanent &> /dev/null
firewall-cmd --reload
#创建网站存放目录
mkdir -p $install_dir/htdocs/zhuawawa.example.com
cp -r files/zhuawawa/* $install_dir/htdocs/zhuawawa.example.com
#重启httpd
systemctl restart httpd
#查看端口
ss -antl
[root@localhost httpd]# ls
apache_lnh.sh config.sh files
[root@localhost httpd]# ls files/
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.53.tar.gz httpd-2.4.54.tar.gz zhuawawa(提前将源码包解压到这里)
[root@localhost httpd]# ls files/zhuawawa/ (此处是我解压的源码包)
Battle_City audio css images index.html js tk.zip
进行访问:
[root@localhost ~]# tar -Jcf httpd.tar.xz httpd/ //压缩脚本存放目录
[root@localhost ~]# ls
anaconda-ks.cfg httpd httpd.tar.xz