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…”
echo “OK… moving on then”
echo “Enter the name of your new site, then press [ENTER}”
# 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
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 !!
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
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
# sh 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 🙂