How to move a site to a new server


upload to server

This tutorial is based on a typical scenario, which is developing on XAMPP locally (Win XP Pro) and deploying on a typical LAMP server environment. The same steps will work for any source server with little or no modification, unless to the .htaccess file or the method of accessing your database.

  1. Install the site locally, renaming and editing the .htaccess file to indicate the subdirectory you are deploying your site into in the test environment, as in the following example with a local development copy of the MODx CMS site at /localhost/modxcms/: RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # If your MODx installation is in a subdirectory, change the following line to match the physical
    # path to the "root" of the site as follows:
    # RewriteRule ^(.*)$ /path/to/subdirectory/index.php?q=$1 [L,QSA]

    RewriteRule ^(.*)$ /modxcms/index.php?q=$1 [L,QSA]
    Rename the ht.access file in the /manager folder to .htaccess. This will turn off the RewriteEngine for that folder.
  2. After developing the site locally (using all relative paths from the site root, to keep it portable), make a copy of .htaccess and call it .htaccess.local, editing the path on the .htaccess file for the remote deployment location as appropriate (usually removing the subdirectory path). The .htaccess file in /manager should be left as it is.
  3. Then make a copy of manager/includes/config.inc.php to config.local.inc.php, and edit config.inc.php with the remote database connection settings for the deployment server (the remote db must be already created and ready to use)
  4. Copy the /manager, /assets, /index.php, and /.htaccess folders and files to the target LAMP server (you can optionally exclude *.local.*). If this is an upgrade and not a new installation, make sure to save your remote site's /assets folder first, then you can re-upload all of your existing content, such as images and templates, if the upload has overwritten any of it.
  5. Unless you are in an environment where the webserver runs as the same username with which file ownership is attributed on the target server, you will need to change permissions on the following directories/files to 777:
    • /assets/cache (and all files ending with .php in this directory)
    • /assets/images
    • /assets/files
    • /assets/flash
    • /assets/media
  6. Dump (export) the local DB contents (use the Backup Manager, or any MySQL client such as phpMyAdmin). In phpMyAdmin, select SQL for the file type. Save to a file on your local machine and note the location. Then go to the remote LAMP server and import the SQL dump you saved into the modx DB (most hosting environments use phpmyadmin for this -- select the database and "import" the SQL file). You will probably want to empty the log tables before backing them up, or else you'll have rows and rows of log data useless to your new server.
  7. Point your browser at http://yoursite.com/manager. After logging in, go to Adminsitration -> System configuration and change the paths for the resource browser (Resource Path and Resource URL in System Settings -> Interface & Editor Settings tab) and the filemanager (File Manager Path at System Settings -> Miscellaneous Settings tab)
  8. Test the remote site. It should be working just the same as your local development site.