Installing WordPress on a Dedicated Linux Server

There are several features of WordPress that work fine, if your blog is installed on WordPress.com, or perhaps other large platforms. But if you are using your own dedicated server, some things might need adjustment. Here’s what I found, on my CentOS server, with WHM cPanel.

Pretty Permalinks

For these to work, mod_rewrite must be installed and enabled.

I added this to my .htaccess file, to enable mod_rewrite:

# 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

There are other ways, notably if mod_rewrite is not installed. To check if it was installed, I opened a terminal and executed the following command line command:

/usr/local/apache/bin/httpd -l | grep rewrite

If the output is ‘mod_rewrite.c’, then mod_rewrite is enabled on your server. (It was!)

I think there are other ways.

UTF-8 Character Set

For some inexplicable reason, WordPress databases are built with the latin1_swedish character set, instead of utf8.

I ran this SQL query to change the collation of the database:

ALTER DATABASE MyDb CHARACTER SET utf8;

And this one (repeatedly) to change the individual tables:

ALTER TABLE <tablename> CHARACTER SET utf8;

More on this issue here:

http://codex.wordpress.org/Converting_Database_Character_Sets

Note that these two simple SQL queries do not change your existing data. They only use UTF8 (and various non-Latin alphabets) going forward. If you imported another database that included, for example, Greek characters, once they get turned into “?????” in the database, that’s it. They are toast. You must make this change before you import such data.

Import HTML files

There is a WordPress plugin for this. But it requires “well-formed” HTML. At first, it would only import the titles of my HTML pages; the content was empty. Then I used the W3C.org validator to correct all HTML errors, and it worked very well. There were images linked to a specific directory (/images), and I had to move that directory and its contents to this domain.

At the risk of being redundant, I’ll repeat that there is no magic to this plugin, especially on the matter of linked image files. If all your HTML files link to images at abc.com/images, and you are now installing at xyz.com, those hard-coded references have to be changed. In my case, I did a global search-and-replace of the 40+ HTML files, using Bluefish HTML editor.

MBstring.

The popular Jetpack plugin recommended that MBstring be enabled. Using WHM –> EasyApache, this is fairly straightforward. Click on “MBstring” in Step 5 – Exhaustive Options List. A better, step-by-step explanation here:

http://forums.cpanel.net/f5/enable-install-mbstring-module-158165.html

All these things can be done, by Googling the symptom/error message, reading the results, proceeding slowly and carefully, and trying things. None of this requires advanced technical knowledge, just common sense, a general understanding of how servers work, what a MYSQL database is, etc. Using the command line to edit a file on your server is a bit annoying, but is do-able.

Importing a Blogger Blog

There were Google issues with my server. It just was not going to happen. Finally, I read a suggestion to import the Blogger-based blog posts indirectly, via WordPress.com. Roundabout, but not really so terrible. In overview, these are the steps.

  1. Export the Blogger-based blog, to an XML file or whatever standard is used.
  2. Set up a temporary new blog on WordPress.com
  3. Import the Blogger-based blog posts. (Google has no issues with WordPress.com.)
  4. Optionally, do any clean-up, tweaking, or category-revision that you want to, while on the temporary WordPress blog.
  5. Export the temporary WP blog.
  6. Import it into your WP blog (the one that you are setting up on your own server.)

This is nowhere near as bad as it sounds.