Tag Archives: Wordpress

Automating WordPress uploads using SSH

WordPress allows automated updates of plugins and the program itself, but it requires FTP or FTPS on the server. I did not want to add an FTP server to my host, and didn’t want to be sending my id/password to my shell account over the net in clear text either.

But then I found out through a few web pages that one can add SSH access to PHP on the server and use that.

All seemed straight forward except my host has password logins via SSH disabled. Must use a private/public key. I tried to carefully follow the instructions in each of the pages above and kept hitting failures.

So this blog entry is to rehash how to do this using private/public keys and how to work around an apparent bug in WordPress 2.7.1 with specifics for Centos 5.

Continue reading Automating WordPress uploads using SSH

WordPress migration to new host

I purchased a new VPS (virtual private server) host and have been moving many blogs I host for myself and others to the new host (Linode — which I’m very satisfied with and recommend highly). There’s multiple ways to do this, including just saving the mysql table as a backup, and reimporting, but since I’ve already created blogs on the new host, using the wordpress export, then import, features sounded like a good idea.

And it was, except for a few potential show stoppers that I hit, and I later cleaned up.

One blog was being split into two. All topics about Second Life were to go into the new blog and everything else carried over with the same blog name.  So theory was to import the data twice into each blog on the new host, then delete unwanted data.

Two issues hit me. In the examples below the old site is named voices.catzilla.org and the new one is www.ellcee-tabak.com

1) Even though I swore I told it to also import thumbnails, it imported the pictures from the old site, but the thumbnails were still IMG SRC’ed to the old site.  ie, the HTML on the new site had the URL of the old site for the thumbnail and the main pic linked on the new site as expected. This required two steps to solve. One was to copy over from the downloads directory manually all files that weren’t imported. The second was a scary find/replace in the database of all links to the old site URL and replace with the new one. Fortunately, it was fairly easy using SQL.

update lc_posts SET post_content = replace(post_content,"voices.catzilla.org","www.ellcee-tabak.com");

Basically find all references two voices.catzilla.org and change to www.ellcee-tabak.com.  

2) The harder one was I couldn’t log onto the blog, at all. Got a permission denied. I had to change the db prefix to get two new sites out of the old one, and doing so caused logon problems. To fix that required a few more edits on the wordpress db tables.

update `lc_usermeta` SET `meta_key` = REPLACE( `meta_key` , 'voices_', 'lc_');
update `lc_options` SET `option_name` = 'lc_user_roles' WHERE `option_name` = 'voices_user_roles' AND 'blog_id' = 0;

Not bad. Of course, back up everything before going into DB surgery like this, cause you could always kill the patient, and that’s not good!

Another minor complication from moving a blog this way is that the blogroll and other lists of links don’t come over. In order to do that, must use OPML data to do so.

I got these steps from googling, but unfortunately lost my browser history and can’t find  now what sites I used to dig this up to give them credit, so feel free to return the favor and don’t give me credit if you blog about this either!

Update: 11 Jan 09

I found a far better way is to simply export and import the mysql data. NOT THE ENTIRE DATABASE (unless you are moving over all your blogs) but just the tables associated with the blog being moved.  This requires access to the database the blog lives in on both hosts.  Since I use MySQL it was as simple as (assuming the db name is wordpress and the table prefix is example_:

mysqldump wordpress  > /tmp/blogs.sql

Then edit the blogs.sql file using a text editor and remove any lines referencing tables that do not begin with your prefix_ and save. Note some lines can be horribly long so use an editor that supports very long lines. I used emacs. 

After editing, transfer file to new host and then simply run “mysql wordpress < blogs.sql” where blogs.sql is the edited and copied file from above. 

Note: You may have to specify -u and -p options to the mysql commands above if they are not specified in a cnf file somewhere.

Finally, after doing that copy your entire wordpress directory tree from source host to destination, checking the wp-config.php file to ensure it all is still set up correctly for the new host.

For those who don’t have access to their databases or doing this makes you nervous, I still think the export/import procedure is the best.

Redirecting back to home after logon

I didn’t exactly like the default behavior of wordpress to send registered users to the dashboard after they log on, so I did a few google searches and found a faq page that looks like it’s out of date. But it got me close enough.

Trick was to go into the wp-login.php file and find the

case login:

… statement, then go down a few lines and change the

$redirect_to = 'wp-admin/'

… statement and change it to just

$redirect_to = '/'

… to get the behavior I wanted.

If your blog isn’t in the root of your domain then that redirect should be to where it sits.