Tuesday, December 09, 2008

Importing WordPress from one box to WAMP

Importing WordPress from one box to WAMPserver

Recently I helped someone setup an organization's WordPress website on her personal computer so she could test things in a sandbox as she learned html, css, etc. I had never used WordPress before, and am not exactly a user of LAMP/WAMP (I'm mostly a .Net developer). Setting this up might have been child's play to a seasoned WAMP/PHP/WordPress person, but it took some effort to get it working, so I thought a blog post might save some time for others.

This solution assumes access (FTP or otherwise) to the source box, since files such as plug-ins and theme files aren't included in exports. This also assumes iis is not running on port 80. I got WAMP to work on port 8080, but for this step-by-step, let's assume WAMP will be running on port 80 (default).

  1. Install WAMPserver.
  2. Start WAMP if it's not already running.
  3. FTP (or otherwise connect for file access) to the source website and download the entire contents of the source wordpress folder (or main www folder if it's your main site) into your WAMP www folder -- probably c:/WAMP/www/mysite (this could take a while)
  4. From a browser, go to http://localhost/ and click on phpmyadmin.
  5. Click "Privileges" tab
  6. Click "Add a new User"
  7. Type a username
  8. Select "Local" from the host (unless you want to be able to access your computer from other computers)
  9. Set a password
  10. Click the radio button "Create database with same name and grant all privileges".
  11. Click "Go"
  12. Edit wp_config.php file with the following information (everything else leave alone):
    ...
    define('DB_NAME', 'putyourdbnamehere'); // The name of the database+user you created in step 7.
    define('DB_USER', 'usernamehere'); // The name of the database+user you created in step 7
    define('DB_PASSWORD', 'yourpasswordhere'); // the password you created in step 9
  13. In a browser, navigate to http://localhost/wp-admin/install.php and write down the password it gives you.
  14. In a browser, navigate to http://localhost/mysite/wp-admin/plugins.php and enable the same ones that are enabled on the source site.
  15. In a browser, navigate to http://localhost/mysite/wp-admin/themes.php and click the same theme running on the source site, and then click "Activate 'themename'" in the top right.
  16. In a browser on the source site, navigate to http://source.site.url/wp-admin/export.php and export the site to a file.
  17. In a browser, navigate to http://localhost/mysite/wp-admin/import.php and click "wordpress" at the bottom.
  18. Browse for the file you just saved, and click the "Upload file and import" button (this could take a long time. Wait until it says "have fun" at the very bottom -- you will probably have to scroll).


    Note: If your import file is too large, you will get an error regarding max file size. To get around this do this:
    1. left-click on the tray icon for WAMP.
    2. On the context menu, navigate to PHP->php.ini.
    3. In the file, scroll down and edit the following line (20M was big enough for me):
      ...
      upload_max_filesize = 20M
      ...
    4. Save the file.
    5. I don't know if you need to restart WAMP or not after that step.


  19. Open c:\wamp\www\mysite\.htaccess (you copied this in step 3, didn't you?) in notepad (or your favorite text editor). Change RewriteBase to "/mysite/" and change RewriteRule to ". /mysite/index.php [L]" and save it
  20. On the WAMP icon in your tray, left click it, and then click Apache->Apache Modules-> and make sure "rewrite_module" is checked. You may have to restart services for this to take effect (not sure).
I hope this is useful to at least one person out there

Labels: ,