Nginx + PHP

Nginx doesn’t use .htaccess files and it doesn’t have mod_rewrite. Thus to properly set up a site to behave like a site that uses mod_rewrite site, this should be added to the config file. Well, this makes WordPress work … so, it works for me.

  location / {
    root   /home/ben/public_html/sitename/public/; #site root
    index  index.php index.html index.htm; #index order
    if (!-e $request_filename) {
       rewrite ^.*$ /index.php  last; # the meat
    }
  }

This uses Ngnix’s dynamic URL rewriting and makes it behave just as you’d expect. Yay! I forgot about this when setting up a site today, caused me a bit of a headache.

Importing MySQL DBs via command line

Okay, so wow. I had a pretty obese database I wanted to move from one server to this one (my Slicehost acct) and PHPMyAdmin just couldn’t handle an 11MB table or something; I was even breaking it down so that it only had to import one table at a time, to no avail.

So naturally this seemed like something that could be done from the command line with ease. Heh.

First, I uploaded the exported version of my gzipped database to the root of my home directory.

gunzip mydb.sql.gz #unzip the database
mysql -u username -p newdbname < ~/mydb.sql

That's it. Seriously.
One thing to note is that I already had '

newdbname

' created. But otherwise it was extremely straightforward (after I spent at least an hour figuring it out :P).

Auto-Update SVN Bash Script

I’ve got at least 4 installs of WordPress on my server and I have them all checked out from WordPress’ SVN repository because uploading WordPress files whenever there is an update is incredibly annoying.

I know this means I may be using unstable and unreliable code and all that, but so far I haven’t had much of an issue. Worst case scenario I have to do a server rollback or something.

But anyway, having something like 4 SVN WordPress Installs it’s become apparent that I need an easier solution to running svn update on all the directories.
SO I MADE A BASH SCRIPT.

The Script

#!/bin/bash
# Updates all of my wordpress installations at once ...

echo '--Updating benwatts.ca';
cd ~/benwatts.ca
svn update

#[..] repeat for the other installs

echo "Done and done.";

Storing the Script

Then I created a bin folder in my user folder

mkdir ~/bin

and moved it there

mv ~/updatewordpress ~/bin/updatewordpress

.

Using it

Unfortunately, to use it you have to specify the path (so …

cd ~/bin; ./updatewordpress

). That kind of sucks. Not a whole lot … but I wanted to be a bit adventurous and make it so that I just have to type ‘updatewordpress’ and it’ll go ahead and do it. As it turns out, at least in my version of linux it already searches ~/bin for shell scripts … so all I had to do was log out and log back in again and now the command is there … NICE!