x
 
Create New Page
 View Previous Changes    ( Last updated by gdmacgou )

Moving Servers - A Robust Method

Changes are made at your own risk and are not guaranteed to work. Always make backups of the database and files prior to implementing hacks. Make a special backup of the file and/or template you are modifying so that you can roll back quickly.

Hacks are dangerous and can cause your site to stop working. They make later updates to ExpressionEngine more difficult; you should track your hacks for post-update re-implementation. 

Most hacks are unnecessary, please review the Development Documentation for information on expanding ExpressionEngine via Modules, Extensions, and Plugins.

Hacks are never officially supported.

Note: Directly modifying the database is not supported, and modifying the exp_sites table can and most likely will break your site.  This is not needed and should only be handled by extremely experienced server administrators with several, verified database backups.
__

Agreed, hacks are dangerous but with little official documentation on transferring a site this wiki is useful for experienced admin’s. The following method was robust for transferring an existing EE system to a new server, and new URL with the least steps required.

Moving Servers and Changing URL. Review the wiki’s below.
Moving Servers
Server_Migration

Find out server details. e.g.
Old Server: Linux, Apache2.0.52, PHP Version 4.3.9, MySQL Server version: 4.1.20, phpMyAdmin - 2.8.0.3
New Server: Linux, Apache1.3.99, PHP Version 5.2.5, MySQL Server version: 4.1.22, phpMyAdmin - 2.11.4

Steps To Test New Server
1. Check the new server for the requirements listed at:
requirements

2. Run the Server Wizard (from above link) - requirements tests passed, MySQL test passed

Steps To Transfer the Site:
0. Back up all everything.

1. Copy all servers files (PHP, HTML, etc) from old server to my computer (not the SQL database yet).

2. Use ‘grep’ and ‘sed’ to change URL’s in the PHP and HTML files from www.myoldsite.com to www.newsite.com.
e.g. changeurl.sh:

grep --'myoldsite.com' public_html/ |
while 
read filename
do
(
  
sed -'s#myoldsite.com#newsite.com#g' $filename
)
done 

3. Upload revised files (PHP, HTML, etc) to the new server resulting in the same file and folder structure in both places (old/new).

4. Set the file and folder permissions on the new server so that they matched the old server. To make sure, then set the file and folder permissions as done with a new install.

5. On the old server: Clear Cached Data. Export the MySQL database, using phpMyAdmin, to a gzipped SQL database dump file.

6. On the new server: Create a new MySQL database with a corresponding user with all privileges.

7. On the new server: Import the gzipped SQL database dump file, using phpMyAdmin.

8. On the new server: Using phpMyAdmin, search for oldsite.com and copy down all tables and fields listed.
A warning: DO NOT use these SQL commands (the string length must be adjusted as well, see below).

update exp_sites set site_system_preferences=replace(site_system_preferences,"oldsite.com","thenewsite.com");
update exp_sites set site_member_preferences=replace(site_member_preferences,"oldsite.com","thenewsite.com"); 

Execute the following SQL commands to change most URL’s: (e.g.‘s)

update exp_categories set cat_image=replace(cat_image,"myoldsite.com","newsite.com");
update exp_forum_boards set board_forum_url=replace(board_forum_url,"myoldsite.com","newsite.com");
update exp_galleries set gallery_url=replace(gallery_url,"myoldsite.com","newsite.com");
update exp_galleries set gallery_image_url=replace(gallery_image_url,"myoldsite.com","newsite.com");
etc
etc
update exp_upload_prefs set url
=replace(url,"myoldsite.com","newsite.com");
update exp_weblogs set blog_url=replace(blog_url,"myoldsite.com","newsite.com");
update exp_weblogs set tb_return_url=replace(tb_return_url,"myoldsite.com","newsite.com");
update exp_weblogs set ping_return_url=replace(ping_return_url,"myoldsite.com","newsite.com"); 

To change the URLs in exp_sites you must either edit this table manually or come up with commands like these (notice s:13 and s:11):

update exp_sites set site_system_preferences=replace(site_system_preferences,"\"site_name\";s:13:\"myoldsite.com\"","\"site_name\";s:11:\"newsite.com\""); 

9. Used the following php command to determine new new server_path:

<?php echo realpath(dirname(__FILE__)); ?> 

10. On the new server: Using phpMyAdmin, search for your previous system path and copy down all tables and fields listed.
Execute the following SQL commands to change path information:

update exp_forum_boards set board_upload_path=replace(board_upload_path,"/www/userx/public_html/","/home/usery/public_html/");
update exp_galleries set gallery_upload_path=replace(gallery_upload_path,"/www/userx/public_html/","/home/usery/public_html/");
update exp_galleries set gallery_wm_image_path=replace(gallery_wm_image_path,"/www/userx/public_html/","/home/usery/public_html/");
update exp_galleries set gallery_wm_test_image_path=replace(gallery_wm_test_image_path,"/www/userx/public_html/","/home/usery/usery/");
update exp_message_attachments set attachment_location=replace(attachment_location,"/www/userx/public_html/","/home/usery/public_html/");
update exp_upload_prefs set server_path=replace(server_path,"/www/userx/public_html/","/home/usery/public_html/"); 

To change the PATHS in exp_sites you must either edit this table manually or come up with commands like these (notice s:30, s:31):

update exp_sites set site_system_preferences=replace(site_system_preferences,"\"theme_folder_path\";s:30:\"/www/userx/public_html/themes/\"","\"theme_folder_path\";s:31:\"/home/usery/public_html/themes/\""); 

11. Now open system/config.php file on the new server. Revised with new database connection information, etc.

updated $conf['db_hostname'"newhost";
updated $conf['db_username'"newuser";
updated $conf['db_password'"newpass";
updated $conf['db_name'"newdb"

12. Change system/index.php file to turn on error reporting - to debug problems if any.
changed line from

"error_reporting(0);" 

to

"error_reporting(E_ALL);" 

13. You should now be able to log into the new server with the new URL: www.newsite.com/system/index.php

Category:Hacks

Category:EE1

Categories: