Automatically install scripts for configuring httpd virtual hosts

  
        

Script exercise, write a script to implement the configuration of the local web server: 1. Check if the httpd package has been installed. If not, use the yum command to install it; (you need to configure the yum source in advance) 2. Cancel the central host. Create 5 new domain-based virtual hosts and provide a test home page with the corresponding FQDN: www.magedu.com, /vhosts/magedu bbs.magedu.com, /vhosts/bbs wp.magedu.com, /vhosts/wordpress pw.magedu.com, /vhosts/pw pma.magedu.com, /vhosts/phpmyadmin 3. Check the modified configuration file syntax. If there is no problem, start the httpd service and ask the service to boot automatically. Start;

#!/bin/bash #Author honway #ScriptName AutoSetWebServer SetYUM() { echo "======================== =======================&" echo "Start backup files." echo "backup your .repo file to .repo.bak!" Echo "====================================================== ; YUM_CONF_DIR=/etc/yum.repos.d/for Y in $YUM_ CONF_DIR/*.repo; do mv $Y $Y.bak &>/dev/null done echo "========================= ======================&" echo "Backup successfully." echo "=============== ===============================" echo "Create a yum config file." cat >> $ YUM_CONF_DIR/yumconf.repo <<EOF [Server] name=Server baseurl=ftp://172.16.0.1/pub/Server gpgcheck=0 enabled=1

[VT] name=VT baseurl=ftp ://172.16.0.1/pub/VT gpgcheck=0 enabled=1

[Cluster] name=Cluster baseurl=ftp://172.16.0.1/pub/Cluster gpgeheck=0

[ClusterStorage] name=ClusterStorage baseurl=ftp://172.16.0.1/pub/ClusterStorage gpgcheck=0 enabled=1

[errata] name=errata baseurl=ftp://172.16.0.1/pub/errata Gpgeheck=0 enabled=0 EOF echo "OK!" echo "========================================== =============" }

CreateTestPage(){ echo "$u" > $URL_DIR/index.html } SetYUM

if ! `rpm -qa

Copyright © Windows knowledge All Rights Reserved