Moving WordPress from Linux to Windows Server

windows_linuxI create a lot of WordPress websites for other people. I create everything on my test server and when the customer is happy with it, I move it to their hosting account. I like to work this way because that means I can do what I need to without worrying about people seeing a site that is half baked. It’s especially true if the company that I’m working for has a site that people are actually using.

Usually my clients are on Linux, which matches my development environment, but recently I had to move a site to a client’s Windows 2003 server.

Here are the steps that I took to put the site up and make it work on a Windows server:

Back up the current live site – for safety’s sake, if there is already a site that is up and running on the server, back it up. Make a copy of all the files and export the database. Not that anything should go wrong, but just in case things don’t work out as planned, you can always restore the old site.

Make sure that the server can run php – Windows servers may need some things to be installed on them to have the ability to run php. Talk to your hosting provider and have them do whatever is needed to allow php to run. Without php, we’re dead in the water. If you have a special permalink structure, which you really should have, then you may also need to ask your hosting provider to Enable Ionic ISAPI-Rewrite Filter. Windows doesn’t use .htaccess, which Linux uses to modify permalinks. iirf.ini provides the same functionality in Windows.

Export database – Login to phpMyAdmin and export the database.

Create new database – Login to phpMyAdmin on the new server and create a database. Import the database that you’ve just exported. Make sure that you keep track of your username, database name and password. We’ll need that later in the process. After the database has been imported, find the wp_options table. You’ll need to change two values. Change both siteurl and home to the url of the new site.

Export files – ftp all the WordPress files from the testing environment to your computer.

Modify wp_config.php – Now that we have the files on our computer, it’s time to modify the wp_config.php file that is in the main directory of WordPress. Remember those database values that I told you to remember? Use them to change the information for DB_NAME, DB_USER, and DB_PASSWORD. Depending on your hosting provider you may need to change the value for DB_HOST. Make sure to look that up with them and make that change too. For it’s

Ftp files – Now that we’ve modified what needs to be modified, we should be ready to place it on the new server. On Windows, htdocs is the main directory for most sites.

Change the Default Document – If you site wasn’t running php until now, you’ll need to change the default document to index.php. On, go to Web/FTP Server > Web Server > Settings and Permissions. Click Select a Directory and set it to the directory that WordPress is running on (probably htdocs, unless you’ve set it up differently).  Under Web Server Setting, fill in the default document as index.php. Allow read write and execute abilities to this file.

At this point, you should be able to go to the site and see it up and running. We’re getting there, but there’s still some really important stuff that we need to take care of.

Modify database with script – If you have internal links in the site then it’s important to modify the content to use the correct urls. There is a nifty script that takes care of it here. Follow the instructions given on that page.

Permalinks – Now it’s time to modify the iirf.ini file. Here’s what’s in my iirf.ini file:

RewriteEngine On
MaxMatchCount 2
RewriteCond %{HTTP_HOST} (^ [I]
RedirectRule ^/(.*)$1 [I,R=301]
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,U]

This takes care of url rewrites the same way that they are taken care of in the .htaccess file.

SMTP for mail – If you allow comments or if you have a contact form or some other form on your site, you really need to allow mail to get through. To do that, install the Configure SMTP plugin. It hasn’t been updated in a while, but that’s OK. It works and hasn’t needed to be updated. Configure the settings for your server.

Make sure that you can upload images and plugins – If you can’t upload images, you’ll need give Anonymous User write access to the wp_content folder. This is something that you are going to have to ask your hosting provider to take care of.

Change reading settings – We’re done and we are ready for the world to see our site. If you had set the site to discourage search engines from crawling while you were in development, now is the time to let search engines in. In WordPress, you’ll find a check box to uncheck in Settings > Reading.

Enjoy your new site on your Windows server!