Last active
December 12, 2015 09:49
-
-
Save jnpkr/4754330 to your computer and use it in GitHub Desktop.
Create new Apache virtualhost on Ubuntu 10.0.4 (Lucid)
This file contains 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 | |
#! Shell script to add domains/websites in apache | |
echo "Enter the domain:" | |
read domain | |
mkdir -p "/srv/www/$domain/public_html" | |
mkdir "/srv/www/$domain/logs" | |
echo "<VirtualHost *:80>" >> "/etc/apache2/sites-available/$domain" | |
echo " ServerAdmin webmaster@$domain" >> "/etc/apache2/sites-available/$domain" | |
echo " ServerName $domain" >> "/etc/apache2/sites-available/$domain" | |
echo " ServerAlias www.$domain" >> "/etc/apache2/sites-available/$domain" | |
echo " DocumentRoot /srv/www/$domain/public_html/" >> "/etc/apache2/sites-available/$domain" | |
echo " ErrorLog /srv/www/$domain/logs/error.log" >> "/etc/apache2/sites-available/$domain" | |
echo " CustomLog /srv/www/$domain/logs/access.log combined" >> "/etc/apache2/sites-available/$domain" | |
echo "</VirtualHost>" >> "/etc/apache2/sites-available/$domain" | |
sudo a2ensite "$domain" | |
sudo /etc/init.d/apache2 reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment