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

Moving servers - ExpressionEngine site to the new host

For some reason you are dissatisfied with your current host and decide to move to another one.
Well, this is a task not for the faintharted. If you are inexperienced in this matter, you may end with a lot of frustration, your site being down or even lost. But if you consider the relevant steps carefully, all moving can be done in a couple of hours.

I. Choosing host and signing agreement

First you should not make mistake in choosing your new host. Googling for “best host” will not help since most of hosting review sites are nothing more than marketing exercises. Still, some review sites are not of this kind and are worth to be studied. One of such hosting review site is Hostjury. You may be sure to find very good hosts on the top of its list.

What should be included in the package of the good host? -  you may ask himself. Well, here is some subjective list:
1) enough disk space and bandwidth;
2) availability of PHP 5 and MySQL 5;
3) competent and quick customer support;
4) availability of cPanel or some analogue, such as Plesk or H-Sphere;
5) possibility to connect to MySQL server using some GUI client, such as SQLyog;
6) possibility to edit php.ini file;
7) high enough the value of MySQL wait_timeout variable;

Let’s comment some items in this list. At least for the time when you will be moving your site to the new server you most probably will need some competent help and you will want to get it as quickly as possible. In order to check availability of sch customer service you can send some pre-sales email to your prospective host. If they will not answer your question in quarter of an hour, then such host is not worth to move your site to.

Availability of cPanel or some analogue, such as Plesk or H-Sphere is also crucial. These Control Panels include many excellent tools for managing your site; you may be sure, you will miss some of the at some time in the future if your hosting agreement does not include one of these. cPanel is currently industry’s standard and is preferable to Plesk or H-Sphere.

Possibility to connect to MySQL server using some GUI client, such as SQLyog is essential for restoring database on the new host. It is not possible to import the database even of the size of couple megabytes using phpMyAdmin interface; and if you will not have possibility to connect to MySQL server with some GUI client, you will be in the mercy of customer support service on all matters relevant to restoring your database.

Possibility to edit php.ini file and the value of MySQL wait_timeout variable might be something you never thought of. Even if it is so, do not neglect these aspects. Using ExpressionEngine you can very easily create script-intensive pages, that is pages which demand a lot of PHP memory and which take a lot of time for MySQL to execute all queries. If you will not have the possibility to edit php.ini file, then you will be not in control of how much PHP memory sripts on your pages can use; and it is quite probable that the default 32MB or 64MB will not be enaugh. If you will be able to edit php.ini then you will solve all your problems with PHP memory by typing in php.ini a line such as

memory_limit=128M;

Sript-intensive pages may also not load if MySQL wait_timeout variable has a small value. You most probably will not be able to edit sql.cnf file in which this value is set; that means you must search for hosting provider which offers packages with the high enough value of this variable. The value of MySQL wait_timeout variable set to 20, 30 or even 50 seconds may not be enaugh for some script intensive pages. Most hosts set the value of this variable quite low; but you can easily find host which is so liberal that this variable is set to hundreds and even thousands.

To have control over php.ini file and big enaugh value of wait_timeout variable is really importantant; without it after creating your first script intensive page and asking why it outputs PHP or MySQL error you will face these options presented by your host:
a) optimize your scripts;
b) move to virtual private server;
c) move to other host.
It is not pleasant to face such options when you are sure that a couple of additional PHP memory megabytes or a couple additional cycles of MySQL server are all what you really need.

Let’s say you found a host which offers a package which satisfies you and its customer service responded to your emails quickly and competently. Now comes signing of the agreement.

When signing agreement you will most probably have an option to transfer your domain registration to a new registrar. Don’t choose this option at the moment of signing agreement. If you choose this option you may not be able to update domain name server information until transferring of domain registration is completed. If you want to transfer your domain registration to a new registrar and you want that your new host charge you for renewing registration, ask your new host for this after domain name server info is updated.

II. Backing up the website

Having signed new hosting agreement it comes time to back up your site on the old host.

1. a) Go CP Home >  Admin >  Utilities >  Clear Cached Data select “All caches” and press “Submit”.

b) Go CP Home >  Admin >  System Preferences >  Cookie Settings and make sure that the field “Cookie Domain” is empty.

c) Go CP Home >  Admin >  System Preferences >  Security and Session Preferences and make sure that the field “Control Panel Session Type” has the value “Cookies and session Id”.

d) Then open website’s phpMyAdmin > databases > my_database > export . Select “drop table”, select “Save as File” and press button “Go”. The database will be exported. Be patient; it may take several minutes to complete.

2. Open export file in text editor which is able to handle large files and delete or comment out the line

CREATE DATABASE `my_database` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `
my_database`;

On the top of export file add the line

SET NAMES utf8;

Without this line after importing the database unicode characters may not be displayed properly.

3. Download all website’s images to your local disk.

4. Download all plugins and extensions you use to your local disk.

III. Preparing new server

From now let’s assume that you have cPanel on your new host.

1. Log into cPanel. Go Databases > MySQL Databases. Enter the name of the new database, eg. “my_database” and click “Create Database”. The new database will be created.

2. Go Databases > phpMyAdmin > Server > Databases you should see your new database. Quite probably neither charset nor collation info will be displayed. To find out which charset and collation your new databases uses go phpMyAdmin > Server > Databases > my_database > Export, make sure that the checkbox “save as file” is deselected and press “Go”. It will be displayed a couple of SQL commands such as

CREATE DATABASE `my_database` DEFAULT CHARACTER SET latin1 COLLATE utf8_swedish_ci;
USE `
my_database`;

That’s not what we need. We need the database which uses utf8 as character set and utf8_general_ci as its collation. In order to change character set and collation, go phpMyAdmin > Server > Databases > my_database > SQL and run this such command:

ALTER DATABASE `my_database` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

3. Go cPanel > Databases > MySQL Databases. Create new MySQL user to the database my_database. Give him all privileges on my_database.

4. Using some FTP program upload ExpressionEngine’s files into the directory public_html and the files of Discussion Forum module into the directory public_html/system/modules/ on the server.

IMPORTANT! Version number of ExpressionEngine on the new server should be the same as that on the old server. Otherwise after importing database you may not be able to log into Control Panel on the new server. If on the old server you use not the current version of ExpressionEngine, you should at first upgrade to the current version and only then proceed with moving your site to the new host.

Install ExpressionEngine using username of just created MySQL user as MySQL username and the password of that user as MySQL password and “my_database” as database name. Then log into Control Panel and install Discussion Forum module.

5. Upload plugins to the directory /public_html/system/plugins and extensions to the directory /public_html/system/extensions on the server.

6. Upload images to the directory /public_html/images/uploads/

IV. Importing the database

1. Got to <a>Webyog</a> site, download SQLyog community edition and install it to your local computer. Connect to MySQL server using username of just created MySQL user as MySQL username and the password of that user as MySQL password and “my_database” as database name and 3036 as number of the port. Then click “Import” on the SQLyog’s toolbar and select export file.
The database will be imported. It may take several minutes to complete.

V. Final steps

1. Find in the “New Account information” your new host has sent to you the Temporary Webpage URL. It may be something like http://194.43.196.121/~my_site/ Then log into ExpressionEngine’s Control Panel, go Admin > System Preferences > General Configuration and make sure that
a) URL to the root directory of your site is http://194.43.196.121/~my_site/
b) URL to your Control Panel index page is http://194.43.196.121/~my_site/eesys/index.php
c) URL to your “themes” folder is http://194.43.196.121/~my_site/themes/
d) Theme Folder Path is /public_html/themes/  To figure out absolute path of the server type this code into any page of the folder in question

<?php echo dirname ($_SERVER[SCRIPT_FILENAME]) . '/'; ?>

e) Default Language is English
f) Default Character Set is utf-8
g) Default XML Language is English
h) Name of your site’s index page is index.php

2. Go Admin > System Preferences > Captcha Preferences and change
a) Server Path to Captcha Folder to /public_html/images/captchas/
b) Full URL to Captcha Folder http://194.43.196.121/~my_site/images/captchas/

3. Go Admin > System Preferences > Emoticon Prefrences and change “URL to the directory containing your smileys” to http://194.43.196.121/~my_site/smileys/ .

4. Go Admin > Weblog Administration > File Upload Preferences > Edit File Upload Preferences and change
a) Server Path to Upload Directory to /public_html/images/uploads/
b) URL of Upload Directory to http://194.43.196.121/~my_site/images/uploads/

5. Go to My Account > Extras > Quick Links and change Link URL of My Weblog into http://194.43.196.121/~my_site/index.php/

6. Now you should have fully functional site on the new server. Check if everything works in your pages.

7. If everything works, then write e-mail to your old host and ask him to send you username and password for your domain. Then go to domain registrar’s webpage and update domain name server info (the list of new domain name servers you will find in the “New Account information” your new host has sent to you).

8. Wait until the new DNS info will propagate through Internet. This will usually take about 24 hours.

9. After 24 hours or so log into Control Panel and change all URLs which start with http://194.43.196.121/~my_site/ into URLs which start http://www.mysite.net

10. Ask your new host to act for you as domain name registrar. In order to transfer domain to the new registrar you will need to contact your old host and get from him EPP code.
That’s it! You have moved your site to the new server and it took only severeal hours of your time. Now you can contact your old host and ask him to terminate hosting agreement.

Related: Complete copy of the website on localhost

Category:Moving servers - Category:Installation - Category:Database - Category:Exporting