Archive for category Wordpress

wp-make-me-happy


Ok this is kind of a repeat but instead of editing the original post I thought I would just repost it in its new form.  I was working on setting up a backup blog of this very blog to have on a local server… I don’t know in case of disaster… actually it was to see what it looked like with some new themes I have as this site is somewhat limited in it’s design choices… not complaining mind you, just wanted to see what it would look like with some nifty designs I made… The original post, WordPress Automation, was from a while back and I had the need to actually make a new host just for this occasion as I had blown away all of my web servers recently (I don’t actually recall why…???).  I was going through my script pad and found a really simple setup script I wrote that was better than the original post I put here… although it really is the same thing just without any comments… LOL Sorry I take for granted that you are just going to trust that it works and run it !!! Scary 🙂  I did find a few hiccups however… My sed lines didn’t take although they are correct… and this was a stinker… The repo I like to create here, although mostly this is if you were going to run multiple vhosts on the same physical server, (It does allow you to have only 1 repo for ALL themes and plugins for ALL users) does NOT work with the Worpdpress Import plugin… So I ended up un-linking the plugins link and just re-instating the original one, good thing I copied it to a backup in this script instead of just blowing it away huh??? 🙂  As I stated earlier, the entire script is based on the setup that Virtualmin creates in its vhost creation module so if you are using something else or doing that manually, you may need to change this up a bit… 29 lines on this one… sorry 😦  LOL

#/bin/bash
#
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
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 .
cd /home/$newblog/public_html/wp-content
mv themes bak.themes # <– Just in case we hose everything 😦
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
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 *
# EOF

, , , , , , , ,

Leave a comment

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.

#/bin/bash

#

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 *

# EOF

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.

http://www.grymoire.com/Unix/Sed.html

Happy Blogging 🙂

, , , , , , , , , ,

3 Comments