Tagged with Wordpress

WordPress PHP Files Downloading Instead of Processed by Server

I was helping a friend who was migrating a WordPress site from one host to another. After moving the files over to the new hosting provider instead of the files being server as PHP files by the web server a download prompt would pop-up to download a file. It turns out this was caused by the .htaccess file from the initial host (that was transferred along with the other files) not being properly configured for the new host. Here’s the initial .htaccess file:

# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
 
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
# END WordPress

Note the AddHandler directive at the top of the file. My attention was drawn to it as the rest of the .htaccess file are the basic directives required by WordPress. This was likely added by the initial host to default .php files to be handled by PHP 5.4. The new host didn’t have support for PHP 5.4, which caused .php files to be mishandled. The issue was resolved by commenting out the line:

# Use PHP5.4 as default
# AddHandler application/x-httpd-php54 .php
 
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
# END WordPress

With this change the site began to function properly.

Tagged , , , , , , ,

Meta – Migrating mice and pen from posterous to wordpress

If you visited my blog before, you might notice that there’s now a completely new look and feel. In this particular case this went well beyond a simple reskin, and actually involved moving my blog completely over from being hosted on posterous.com, to being hosted on my own hosting using WordPress.

I made this move for one larger reason, and several smaller ones. The main reason is simply that my other blog, springlaunched.com is hosted using WordPress, and I’ve fallen in love with the quality of the tools that come with WordPress, and the functionality available through the large number of community plugins.  The smaller reasons may be outdated as Posterous has been busy making improvements, but these are what initially drove me to use WordPress:

  • Difficulty doing code highlighting
  • Frustrating web-based editing interface
  • Frustrating interface for working with assets (images, etc.)

My intention is not to start a flame war between WordPress and posterous, but I’ve been very happy with WordPress and would rather only be using one platform across my various blogs, so I wanted to move this blog over to WordPress.  This is a quick record (written in WordPress) of the process of migration.

First I created a temporary WordPress site to give me a location to migrate my posterous site to.  I use dreamhost for the hosting of this blog, and they have a “1-click” install for WordPress which made this very quick and easy to do.  Following the basic WordPress setup (create admin account, give the blog a name, etc.), I went to Tools > Import hoping to see posterous.  Unfortunately posterous is not one of the default import options in WordPress.

Fortunately a quick search of the available WordPress plugins yielded a posterous importer which I was able to install.

After installing the posterous importer plugin, posterous showed up as an option in WordPress under Tools > Import.

Clicking on the now available “Posterous” option yielded a basic form with a few fields that needed to be filled in with my posterous info.

After clicking “submit” the plug-in ran off and was able to grab all my posts and comments from my posterous blog and pull them over to my new WordPress blog.  Once I had all my posts pulled over I wanted to install Disqus, which is the comment system I use on Spring Launched, and which I like because of it’s social media integrations.  This was a fairly straightforward process to install using the plugin system in WordPress, and to setup by going to “settings” in the list of plugins under “Disqus Comment System”, and then selecting “install” at the top right of the settings page.

To import my existing comments I then had to go to the “import/export” section of the Disqus settings, and tell it to import the existing WordPress comments into Disqus.

The last step I had to take to get my content all moved over was to add syntax highlighting to my WordPress blog as several of my posts from posterous had code embedded in them, and the porting process lost much of the formatting.  After a little bit of research I came across the WordPress plugin “WP-Syntax”, which gave me the functionality I needed.  To actually convert the code that had been imported from posterous to the format supported by WP-Syntax took a bit of montonous copy/pasting, but it achieved the desired result.  It is worth noting that if I had a large amount of code in my posterous blog this would have proved quite a cumbersome task!

In order that my old backlinks would correctly work, I wanted to maintain the URL format that posterous uses for it’s posts.

Posterous:

WordPress default:

This setting can be changed in WordPress under Settings > Permalinks:

At this point I had my temporary wordpress instance on dreamhost working like I wanted to, so now I needed to move it over to zittlau.ca where I wanted it to be hosted.  First I needed to change the domain in the wordpress general settings.

Then I simply setup zittlau.ca as a fully hosted domain in dreamhost, and then connected through ssh and used the linux command “cp” to copy the files over:

macbook: Ben$ ssh argonauts.dreamhost.com -l [my_login]
[argonauts]$ cd zittlau.ca
[argonauts]$ cp -r ../migrate.zittlau.ca/* .

Using the terminal may be intimidating for some who are not familiar with the command line. If you belong to this camp you can accomplish the same thing through ftp by copying the files from the temporary folder to the folder for the permanent location.

At this point the migration was pretty much complete, and I was ready to unleash my new WordPress based blog on the world!  The one step I didn’t talk about here is moving the DNS from pointing to posterous, to get it to point to the new host.  This will be dependent on your setup, but if you have any questions about this step leave them in the comments and I’ll do my best to help!

Happy Blogging!

Tagged , , , , , ,