How to Migrate an OSCommerce Store to a New Server / Web Host

This article covers how to move an existing OSCommerce shop from one web host or server to a new web host or server.

Sections of this article:


1) Download ALL files from server.

Connect to the old server and download all files for exact copies.

2) Create backup of Database through MYphpAdmin

Log into MYphpAdmin and export the store database, uncompressed to a location on your PC. Also log into the OSCommerce store admin area, click tools and create a backup of the database to also save to your PC. The database created through MYphpAdmin will probably be called localhost.sql

3) FTP files to NEW SERVER

Log onto your new web server via ftp and upload all store files in binary. Note the includes/configure.php file may re-write its permissions which will need to be corrected later.
You may need to correct permissions on other oscommerce files and folders as per the oscommerce installation guide.
Files and folders include; catalog/images to 777, catalog/includes/configuration.php to 644 (444 on some servers) catalog/admin/includes/configuration.php to 644 (444 on some servers), catalog/admin/backups to 777 and catalog/admin/images/graphs to 777. See OSCommerce installation manual for correct permission settings on this file.

If you use the HeaderTags SEO contribution you may need to change the file permission for catalog/includes/header_tags.php to 755 (or 777). See documentation for Header Tags SEO.

4) Install Database on NEW SERVER through MYphpAdmin

Log onto your MYphpAdmin and create a NEW DATABASE, this will be your new database for your oscommerce store, you can use the same name as your old database if possible as this will make things easier.

Assign a user to the database, again if you can use the same user as your old database it will keep things simpler.

We now need to edit the exported database of your old store. We'll be using the localhost.sql file generated by MYphpAdmin previously.
Open this file in notepad, dreamweaver or your preferred html/code editing application and find the following entries.

  • Find the entry on line 19: " -- Database: `database_name` " and change to the correct name of your NEW DATABASE you created earlier. eg: `newdatabase_name`
  • Then find the entry on line 21: " CREATE DATABASE `database_name` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; " and change to the correct name of your NEW DATABASE. eg: `newdatabase_name`
  • Then find the entry on line 22: " USE `olddatabase_name`; " and change to the correct name of your NEW DATABASE you created earlier. eg: `newdatabase_name`
  • Lastly find line 21 & 22 where it says " CREATE DATABASE `database_name` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
    USE `database_name`; "
    Delete these two lines. This prevents MYphpAdmin creating the database again.

Note: If you have ever restored your OScommerce database you will find entries of this in the sql file as well. Just search for your database_name within the sql file to find all entries. Dreamweaver's search results feature is good for this.
Note2: It's probably possible to create the new database using the localhost.sql file and not deleting the entry on line 21 & 22 as described above. This was merely the procedure we took and have explained here.

5) Change variables in 2 configure.php files

In includes/configure.php and admin/includes/configure.php you need to change some variables to make the store re-install work. Open these files in notepad, dreamweaver or your preferred html/code editing application.

If your store is going to be installed in the root on your new server you only need to edit a few values. These would include DB_DATABASE, DB_SERVER_PASSWORD, DB_DATABASE_USERNAME, DIR_FS_CATALOG, HTTPS_COOKIE_DOMAIN, HTTP_COOKIE_DOMAIN, HTTPS_SERVER, HTTP_SERVER.

If you want to install your OSCommerce store into a DIRECTORY on your NEW SERVER and previously it was installed in the ROOT of your OLD SERVER then do the following.

  • If you are uploading the copied site to a Directory you need to specify this in the following files: includes/configure.php - admin/includes/configure.php.

### includes/configure.php ###
[where 'store' is the new directory name. where 'user' is your server account address. where 'yourdomainname.co.uk' is the web domain of your new website.]

<?php

define('HTTP_SERVER', 'http://yourdomainname.co.uk');

define('HTTPS_SERVER', 'http://yourdomainname.co.uk');

define('ENABLE_SSL', false);

define('HTTP_COOKIE_DOMAIN', 'yourdomainname.co.uk');

define('HTTPS_COOKIE_DOMAIN', 'yourdomainname.co.uk');

define('HTTP_COOKIE_PATH', '/store/');

define('HTTPS_COOKIE_PATH', '/store/');

define('DIR_WS_HTTP_CATALOG', '/store/');

define('DIR_WS_HTTPS_CATALOG', '/store/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');

define('DIR_FS_CATALOG', '/home/user/public_html/store');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');

define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

define('DB_SERVER', 'localhost');

define('DB_SERVER_USERNAME', 'database_user');

define('DB_SERVER_PASSWORD', 'userpa33word');

define('DB_DATABASE', 'database_name');

define('USE_PCONNECT', 'false');

define('STORE_SESSIONS', 'mysql');

?>
-------------------------------
### admin/includes/configure.php ###
[where 'store' is the new directory name. where 'user' is your server account address. where 'yourdomainname.co.uk' is the web domain of your new website.]

<?php

define('HTTP_SERVER', 'http://yourdomainname.co.uk/store');

define('HTTP_CATALOG_SERVER', 'http://yourdomainname.co.uk');

define('HTTPS_CATALOG_SERVER', 'http://yourdomainname.co.uk/store/');

define('ENABLE_SSL_CATALOG', 'false');

define('DIR_FS_DOCUMENT_ROOT', '/home/user/public_html/store/');

define('DIR_WS_ADMIN', '/admin/');

define('DIR_FS_ADMIN', '/home/user/public_html/store/admin/');

define('DIR_WS_CATALOG', '/store/');

define('DIR_FS_CATALOG', '/home/user/public_html/store/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . 'images/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

define('DIR_WS_CATALOG_LANGUAGES', DIR_WS_CATALOG . 'includes/languages/');

define('DIR_FS_CATALOG_LANGUAGES', DIR_FS_CATALOG . 'includes/languages/');

define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');

define('DIR_FS_CATALOG_MODULES', DIR_FS_CATALOG . 'includes/modules/');

define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');

 

define('DB_SERVER', 'localhost');

define('DB_SERVER_USERNAME', 'database_username');

define('DB_SERVER_PASSWORD', 'userpa33word');

define('DB_DATABASE', 'database_name');

define('USE_PCONNECT', 'false');

define('STORE_SESSIONS', 'mysql');

?>
--------------------------------

6) Edit .htaccess file for SEO Url's Contribution.

If you are using the SEO Url's Contribution
[http://www.oscommerce.com/community/contributions,2823] and your NEW SITE is installed in a SUB FOLDER on your NEW SERVER where previously it was in the ROOT of your OLD SERVER you need to make changes to your .htaccess file in the catalog/ directory.

Open the .htaccess file in your preferred html/code editing application and find this entry on line 4: RewriteBase /
and change to: RewriteBase /store/
[where 'store' is the directory name]

Conclusion:

We hope you found this useful and informative. We accept there may be better methods or approaches to moving an OSCommerce Store to a New Server but please feel free to comment below with any additional information.
Equally please feel free to link to this article as it may be of interest to others facing a similar problem.

Dated: August 26th 2010

< Back to Knowledge Base