Page 1 of 1

Migrating from one server to another (cPanel 11 hosts)

Posted: Mon Nov 19, 2007 12:37 am
by kermit
Moving a CMSMS site from one server or location to another (with cPanel 11 notes):

On "Old" site:

1. backup database (in phpMyadmin: "export", ensure all tables are selected.. they should already be, and "save as file")
2. download contents of ./uploads directory (cPanel FileManager: navigate to cmsms root, select 'uploads' directory, create a zip archive, 'uploads.zip' and then download it)

On "Old" site, if necessary:

3. download contents of ./modules directory (cPanel FileManager: navigate to cmsms root, select 'modules' directory, create a zip archive, 'modules.zip' and then download it)
4. download any other files needed, such as custom or changed plugins


On "New" site:

5. NEW install of CMSMS (same version as "Old" site) - the NEW install ensures your config.php is set up properly from the start. your added modules will be restored by uploading the modules and importing your old database; later on...
6. configure pretty URLs and mod_rewrite, if needed
7. clear cache in admin panel
8. replace contents of new install's database (that you created and used in step 5) with your backup (phpMyAdmin: drop all existing tables and then "import" the backup)
9. upload old site's ./uploads directory (cPanel FileManager: delete existing 'uploads' directory, upload 'uploads.zip' to cmsms root and extract)

On "New" site, if necessary:

10. upload old site's ./modules directory (cPanel FileManager: delete existing 'modules' directory, upload 'modules.'zip' to cmsms root and extract)
11. upload or replace, as needed, other files, such as custom or changed plugins

Then..

12. check and change permissions, as needed and if necessary, especially on files just uploaded to ./modules, ./uploads, etc.



ALTERNATE, using cPanel 11 Filemanager to transfer ALL files at once; uploads, modules and everything else:

replacing 1-4 above ("Old" site):

a. peform step 1, above.
b. clear cmsms cache in admin panel and logout
c. in cPanel FileManager: navigate to cmsms root, select 'all' except directories or files not part of cmsms (such as cgi-bin), create a zip archive 'cmsmsfiles.zip' and then download it.

replacing 5-12 above ("New" site):

d. in cPanel FileManager: navigate to what will be the cmsms root, upload 'cmsmsfiles.zip' and extract.
e. check and change permissions, as needed and if necessary.
f. import database backup into a new database, creating the database and user if needed.
g. change config.php database connection details, URLs and paths as needed. pay particular attention to database details and paths!
DO NOT REMOVE "OLD" SITE UNTIL YOU ARE CERTAIN THE "NEW" ONE IS WORKING FULLY AND PROPERLY
File permissions:

./modules and everything in it must be server-writable to use ModuleManager
./uploads and everything in it must be server-writable to use FileManager or ImageManager.
./tmp/templates_c and ./tmp/cache must be server-writable.

1. If PHP runs as your user.. use 755 on directories, 644 on files (that must be writable by php).
   a. 600 or 400 for files that only need to be writable or readable by php and not apache (such as config.php)
   b. do not set scripts, or directories they are in, writable by 'group' or 'other'.
2. If using PHP as a module and PHP runs as webserver.. use 777 on directories, 666 on files (that must be writable by server)
   b. 755 or 644 for directories or files that only need to be readable by server (and read/writable by you, as your user, via FTP).

The "test" next to the umask setting in cmsms global settings will tell you what user PHP runs as.

If run as webserver, you may want/need to change umask to enable full functionality of admin features (must be owner-writable), or allow you, as your user, to access/maintain files via FTP or a web-based filemanager (must also be writable by 'other').

if run as your user, 022 should work fine and test should report back: Owner: yourusername; Permissions: Owner: Read/Write, Group: Read, Other: Read.

On my own (cPanel 11 based) servers, PHP4 as a module is the "default" PHP (running as the webserver user), and PHP5 as CGI running under the user's account is available by adding a line to the top of .htaccess in cmsms root:

# to force PHP5, comment out to use server default (PHP4 as module)
AddHandler application/x-httpd-php5 .php

# for PHP4 as a module, comment or remove these if using PHP5, above.
#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

How your own server performs this trick may be different. Note that changing which version, if it also involves changing what user PHP runs as, will require changes to file permissions before everything works right.

I've been moving all CMSMS sites (ours or ones we maintain) over to PHP5 in preparation of the looming end of support for PHP4 and have been urging our hosting customers to do the same with their own sites/scripts.

If you are setting up a new hosting account on a cPanel host (or anywhere, really).. please configure the account to use PHP5 by default as the latest versions of CMS Made Simple require it!  I can also highly recommend running PHP5 as your user (via suExec or similar method) as it does make things easier to manage not having to deal with permissions issues (e.g. web server vs user)

Note: this is a checklist, not a tutorial; it does not walk through every step and requires you to already know how to navigate and use the cPanel control panel, phpMyAdmin, FileManager, and how to create new databases and users. It requires no shell access, and doesn't even use FTP if you use cPanel's built-in FileManager. SSH does help, if you know how to use it, and need to do some recursive file permission changes.

Re: Migrating from one server to another; with some cPanel 11 notes

Posted: Tue Nov 20, 2007 8:14 pm
by Pierre M.
Hello kermit,

you have write access to http://wiki.cmsmadesimple.org/index.php/How_to with your forum account. Enjoy :-)

Pierre M.