Wordpress Automation

OK so I had a few minutes to spare today and I  decided to finalize this mini-automation script for WordPress installs.  Keep in mind that  the assumption is made that you have used Virtualmin to create the preliminary aspects, vhost, mysql, doc root, etc… If not… this ain’t gonna work as it is.  I guess I could work up a more in-depth script to include these aspects, in fact that is how I started this idea in the first place, but the aspects of virtualmin really are pretty extensive and since I am using that to manage the vhosts anyway I just skipped that part, I mean why try to improve on a great integration aspect, besides it is unlikely I could do it better anyway.  I would however like to translate this piece into a Perl mod to be added to the virtualmin GUI, that would be a cool improvement.



echo “Make sure you have created this VHost using virtualmin FIRST…”

sleep 5

echo “OK… moving on then”

sleep 2

echo “Enter the name of your new site, then press [ENTER}”

read newblog

# You need these if you are NOT using virtualmin FIRST !!

# mkdir /var/www/html/$newblog

# useradd -c ‘$newblog user’ -p ‘$newblog’ $newblog

# chown -R $newblog:$newblog $newblog

cd /home/$newblog/public_html

wget http://www.wordpress.org/latest.tar.gz

tar xzf latest.tar.gz

rm -Rf latest.tar.gz

mv wordpress/* .

rm -Rf wordpress

chmod 777 .

# Link the themes & plugins from the default repo

# This makes the assumption that you actually HAVE a repo for themes and plugins…

# If you don’t this ain’t gonna do what we need it to !!

cd /home/$newblog/public_html/wp-content

mv themes bak.themes # <– Just in case we hose everything 😦

# Make the link directorie(s), if necessary and link ’em up

mkdir -p /var/www/repo/themes

ln -s /var/www/repo/themes /home/$newblog/public_html/wp-content/themes

mv plugins bak.plugins

mkdir -p /var/www/repo/plugins

ln -s /var/www/repo/plugins /home/$newblog/public_html/wp-content/plugins

cd ../

cp wp-config-sample.php wp-config.php



# Final directions

# Open the editor if needed but SED will do what you need

# vi wp-config.php

sed -i ‘s/putyourdbnamehere/’$newblog’/’ wp-config.php

sed -i ‘s/usernamehere/’$newblog’/’ wp-config.php

sed -i ‘s/yourpasswordhere/’$newblog’/’ wp-config.php

chown -R $newblog:$newblog *


If you need webmin/virtualmin/cloudmin (I HIGHLY recommend them) you can spin this off:

# Virtualmin/Webmin/Cloudmin Installation

# cd /usr/src

# wget http://software.virtualmin.com/gpl/scripts/install.sh

# sh install.sh

# wegt http://cloudmin.virtualmin.com/gpl/scripts/cloudmin-gpl-redhat-install.sh

# sh cloudmin-gpl-redhat-install.sh

And that’s it! Just navigate to your new URL (assuming that you made the proper DNS entries…) and configure WordPress from its admin console.  I also thought this tutorial on SED was pretty useful although what I used here is very basic, just in case you need something more.


Happy Blogging 🙂


, , , , , , , , , ,

  1. #1 by Home improvement on April 21, 2010 - 3:41 am

    thanks for your info, now I can improve my homepage.

  2. #2 by gmconklin on April 20, 2010 - 4:17 pm

    I guess I should mention the implied fact that I have successfully tested this on CentOS 5.4… Maybe I should have said/done this first??? Nawww… I knew it would work 🙂

  1. wp-make-me-happy « A Technological Farce

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: