How do I move my site from one server to another?

Requested by Carnuke and Answered by Jdseymour on 2004/11/5 18:29:29

How do I move my site from one server to another?

Moving your site exactly as it is from one server to another is a quite simple task.

a) Upload exactly the same files as on the first server to the second server
b) Export the database from the first server to the second server, using a tool like PHPMyAdmin
c) Modify mainfile.php on the second server to have the correct physical path, URL and database connection details
d) On the second server, set cache, templates_c and uploads directories to be writeable by the server and set mainfile.php to be read-only

See also this FAQ here

For more detailed account of site migration, see below.

--- Additional details submitted by Jdseymour on 2005/1/20 22:21:02

The first thing that you want to do, and should even do this when not migrating, is download an updated exact copy of your website with full directory structure intact. You can easily do this with your favorite FTP program.

I also, in cPanel (my preferred control panel) do a full site backup, database backup, and a home directory backup. This can be accomplished in cPanels backup utility. The home directory and the database backup will download to disk automatically in gzip format. The full site backup will be created and is found in your website's home directory. Use an FTP program to download it.

Why the three types of backups? Redundancy, if something goes wrong I can restore the full site or part of it easily in the cPanel backup utility restore function.

So we now have our website copied to disk, and our backups. We now need to upload all website files to the new servers root directory, with exact directory structure intact. Once this is done check all your folder permissions and adjust as required. For certain the uploads, template_c and the cache folders should be chmod 777, but also other folders required by modules also need to be adjusted to writable.

Next we need to work on the database.

No cammand line interface to the site. That left me with one option, PHPmyadmin.

The only problem with restoriing, or installing a database with PHPmyadmin is the script timeout error. PHPmyadmin can load small databases with no trouble, but if you have a larger database, more than 2.5 to 3MB the operation will time out. My database is a little over 7MB so there was no way for me to install the full database with PHPmyadmin.

OK. So I have 144 tables with 7 mb of information. How would I get this database installed?

The solution was to break the database up into smaller chunks and install it a piece at a time.

I logged in to PHPmyadmin on my former site and exported sections of the database keeping whole module sections intact. In all I divided the database up into seven 1MB chunks. Had seven folders on my local computer named , restore1, restore2 and so on.

When you export from PHPmyadmin check the following options in the export options: SQL, Add DROP TABLE, Add AUTO_INCREMENT, Enclose table and field names with backquotes, Use hexadecimal for binary fields, set the export type to INSERT, set the filename template to _DB_, and tick to export in "gzipped" format. Select the tables that you want to export (hold down the CTRL key while clicking multiple tables for export.)

Next I logged in to PHPmyadmin on the new site and installed each table chunk to the database. To do this click on the SQL tab, click on browse, a file browse window appears, locate and select the file then click the go button. The file will be uploaded then installed to the database. Once completed PHPmyadmin will give you a success or failure screen with the number of operations performed.

Once all of the tables are installed click on the Structure tab, scroll to the bottom, click on check all (which just puts a check mark by all tables). There is a dropdown list titled With Selected, click on that and select Analyze Table.

Click the Structure tab again and click on Check All. Go back to the dropdown list and select Repair Table. All tables should be listed with an "OK" by them.

So now we have the website and the database installed. Now we need to configure mainfile.php.

The permissions settings for mainfile.php should be OK by default for what we want to do now. Get out your favorite text editor open the copy of minfile.php in your site copy on your local computer. Check the entries for :

Quote:

// XOOPS Physical Path
// Physical path to your main XOOPS directory WITHOUT trailing slash
define('XOOPS_ROOT_PATH', 'var/www/html/yourURL.com/yourxoopsfolder');

// XOOPS Virtual Path (URL)
// Virtual path to your main XOOPS directory WITHOUT trailing slash
define('XOOPS_URL', 'http://www.yourURL.com/yourxoopsfolder');



And make any necessary changes. then check all your database information entered in the file, and make any necessary changes.

Copy mainfile.php to your new server replacing the original. Use the cPanel File Manager utility and chmod mainfile.php to 0444. This make this file read only.

Now the only thing left to change is the DNS setting of your domain name. You should have been provided with a primary and secondary DNS server hostname or IP address by the hosting provider. Go to your domain name providers control panel and change the pointers to these provided servers.

It will take some time, usually several hours to one day for the new DNS settings to propagate throughout the internet. At that time your domain will go to the new site location instead of the old one. The old site can be taken offline anytime after the change is made.

This Q&A was found on XOOPS Web Application System : https://xoops.org/modules/smartfaq/faq.php?faqid=193