Created
December 23, 2015 20:22
-
-
Save obiPlabon/e8e1f2ea300d47ac3528 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| hostName=$1 | |
| echo "$hostName creation procedure starts" | |
| # create directory at /var/www/ | |
| sudo mkdir /var/www/$hostName | |
| # goto apache dirctory | |
| cd /etc/apache2/sites-available | |
| # create config file | |
| sudo touch $hostName.conf | |
| sudo chmod 0777 $hostName.conf | |
| # write virtual host config | |
| echo -e "<VirtualHost *:80>\n\tServerName $hostName\n\tDocumentRoot /var/www/$hostName\n\tErrorLog ${APACHE_LOG_DIR}/error.log\n</VirtualHost>" > $hostName.conf | |
| # Enabled this site | |
| sudo a2ensite $hostName | |
| # Restart apache after enabling this site | |
| # so that everything works perfectly as expected | |
| sudo service apache2 restart | |
| sudo echo -e "127.0.0.1\t$hostName" >> /etc/hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment