Posts Tagged LAMP

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

Advertisements

, , , , , , , ,

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

VHost from hell…


Well I thought this would be a funny story to share to showcase my relative incompetence… Hey, I am a guy who can take BEING the joke… So I am playing around with my fav blog app, WordPress, and I have well a bunch of sites locally that I work on… All beta/test sites, all internal so basically just for me and my co-workers if they like.  I thought it may be cool to host all of my WordPress sites on 1 physical device instead of on 5 like I have now… So I began my journey into  accomplishing this. F! I just spilled Loganberry on my shirt… (it stains quite badly)… OK… so for the last hour I have been trying to get this to work and in one way or another it just doesn’t.  First, as I am on a Windows domain, I thought I would add the CNAME’s to the DNS host.. ya know to make life easier… So I did that… and everything was working as expected… Next it was time to create the WordPress installations for each individual site.  No biggie there either, except for the mysql aspect where I was not able to make it work with any other user other than root.  Which for me is not a problem in this environment, but it certainly is not the right way to do it.  I guess I don’t know what group I need to create or add the new user to to make the mysql database work properly or at all with the mysql user I created for the new databases.  So I just gave up on that for the time being.

Examples of what I tried:

NameVirtualHost *:80

<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/wordpress
ServerName wordpress.proserve.local
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

NameVirtualHost 192.168.11.39:80

<VirtualHost 192.168.11.39:80>
#    ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/wordpress
ServerName wordpress.proserve.local
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

NameVirtualHost 192.168.11.39:80

<VirtualHost 192.168.11.39:80>
#    ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/wordpress
ServerName wordpress.proserve.local
ServerAlias wordpress
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

root@centOS54 wordpress]# host wordpress
wordpress.proserve.local is an alias for centos54-a.proserve.local.
centos54-a.proserve.local has address 192.168.11.39

[root@centOS54 wordpress]# pwd
/var/www/html/wordpress/wordpress

And none of this worked properly.  It renders a site, but none of the WordPress theme components are visible.   If I comment out all of the VHost crap and just use the complete path in the URL, like this http://centOS54-a/wordpress/wordpress … everything is fine for this and all of the other sites I have created.  So I must be missing something simple on this, which is very annoying to say the least. Well enough of this for now… I will add as I achieve more success or someone that sees my foolishness makes a comment to help me out !!

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/html/wordpress/
ServerName wordpress.proserve.local
ServerAlias wordpress
ErrorLog /var/log/wordpress_error.log
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/blahville/wordpress/
ServerName blahville.proserve.local
ServerAlias blahville
ErrorLog /var/log/blahville_error.log
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/annlee/wordpress/
ServerName annlee.proserve.local
ServerAlias annlee
ErrorLog /var/log/annlee_error.log
</VirtualHost>

, , , , , , , , , ,

2 Comments