Created
August 2, 2014 12:25
-
-
Save teledirigido/bb76d7c5eea988af527e to your computer and use it in GitHub Desktop.
Add new website via Bash script. Working with Ubuntu server.
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 | |
if [[ $EUID -ne 0 ]]; then | |
echo "You must be a root user" 2>&1 | |
exit 1 | |
fi | |
echo "<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName $1 | |
ServerAlias www.$1 | |
DocumentRoot /var/www/$1/public_html | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost>" > /etc/apache2/sites-available/$1.conf | |
sudo a2ensite $1 | |
service apache2 restart | |
mkdir /var/www/$1 | |
mkdir /var/www/$1/public_html/ | |
chown -R www-data:www-data /var/www/$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment