Last active
August 29, 2015 14:22
-
-
Save danielpataki/d597478c433a219b17b5 to your computer and use it in GitHub Desktop.
Site Creation Automation
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
echo Making site $1 directory... | |
mkdir /var/www/html/$1 | |
echo Creating apache configuration file... | |
sudo touch /etc/apache2/sites-available/$1.conf | |
echo Writing configuration file... | |
echo "<VirtualHost *:80> | |
ServerName $1.$2 | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/html/$1 | |
ErrorLog \${APACHE_LOG_DIR}/error.log | |
CustomLog \${APACHE_LOG_DIR}/access.log combined | |
<Directory /var/www/html/$1> | |
Options -Indexes +FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
</VirtualHost>" > /etc/apache2/sites-available/$1.conf | |
echo Activating site | |
sudo a2ensite $1 | |
echo Reloading Apache | |
sudo service apache2 reload | |
if [ -n "$3" ] | |
then | |
echo Downloading and installing WordPress | |
cd /var/www/html/$1 | |
sudo -u vagrant wp core download | |
sudo -u vagrant wp core config --dbuser=root --dbpass=root --dbname=$1 | |
sudo -u vagrant wp db create | |
sudo -u vagrant wp core install --url=$1.$2 --title=$1 --admin_user=danielpataki --admin_password=yourpassword --admin_email=youremail@email.com | |
sudo -u vagrant wp plugin delete hello akismet | |
fi | |
echo All Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Site Creation Automation On A Vagrant Box
This is a script I made for myself that allows me to create a virtual host with an optional WordPress site working in about 5 seconds. You invoke the bash script like this:
sudo bash make_site.sh mysite local yes
The three parameters are:
The result of this command will be a website at mysite.local with WordPress installed and running. There are a few things to note before running this script:
The script does the following things: