Modx Revolution is now my content management framework of choice. It got my attention a few years back when it won the Packt's Most Promising Open Source CMS award. Before now, I was happy doing my hobby-ish coding by hand (n) while experimenting with popular MVC frameworks and some procedural PHP offerings.
For me, some of the attractions in Modx Revolution include multiple sites from a single install base, easy templating from pure html, seo optimization out of the box, effective ajax functionality for the backend, flexible extendibility through template variables, chunks, snippets and robust plugins, comprehensive system settings with provisions for manual overrides, granular security management and a great community.
Like most developers, I do my development work on my local machine using Wampserver as platform. There is a Modx Extra called Provisioner and a tutorial, Moving Your Site to a New Server, that help to move installations between locations but I prefer to do mine manually. It probably is a bit involved but it provides me with some transparency. The following is how I go about it.
You will need to know the path of your live server. For this illustration I will use "\home4\mydomain\public_html\modxtest" as the full path of the live server. Also, I will assume that you organise your websites in folders under the www web root directory. I use Notepad++ for my coding and screenshots, so you may want to download that.
- in manager, clear the site cache and log out.
- take a copy of your database. I use phpmyadmin to output my database in sql format as I will be editing it later.
- delete all the cache folders under core/cache as they will be recreated as needed.
- take a copy of the development website folder (we will call it 'localsite') under wamp/www directory and rename that copy to 'livesite' as a working name.
- for your apache friendly url, open the .htaccess file in the 'livesite' folder and set the RewriteBase to the subdirectory of your live server if you are hosting in a subdirectory, for example "/modxtest/", else leave as a single forward slash if the live site is directly under public_html, or similar.
- make livesite/core/config/config.inc writable
- this is the main tricky bit and should be approached with extreme care: you certainly must not get it wrong. In Notepad++, click on Search on the Main menu and select Find in Files. Find "C:/wamp/www/localsite" and 'Replace in Files' with "/home4/mydomain/public_html/modxtest" - substituting your directory structure, of course, and making sure that the search directory is the 'livesite' folder, as in the image example below.
This exercise is to change all references of the local site's file structure to that of the live server. - open livesite/config.core and check that MODX_CORE_PATH is pointing to the correct live server path, for example "define('MODX_CORE_PATH', '/home4/mydomain/public_html/modxtest/core/');".
- open livesite/core/config/config.inc and make sure of your database settings:
- $database_type = 'mysql';
$database_server = 'localhost';
$database_user = 'live server user name e.g. mydomain_usermodx';
$database_password = 'live server password';
$database_connection_charset = 'utf8';
$dbase = 'live server database name e.g. mydomain_modx';
$table_prefix = 'modx_'; - assuming you specified a prefix for during installation
$database_dsn = 'mysql:host=localhost;dbname=live server database name e.g. mydomain_modx;charset=utf8';
$config_options = array (
);
- $database_type = 'mysql';
- still in livesite/core/config/config.inc, use Search and Find "url='/localsite" and 'Replace All' with "url='/livesite". You must give the correct paths of both local and live server, as per the image example below:
There should be 4 lines altogether for Modx Revolution 2.1. We do this in order for the manager to function properly. - set read only flag back on livesite/core/config/config.inc.
- Open your database backup in Notepad++ (or your preferred text editor) and do a search for any reference to "C:/wamp/www/localsite". Change that to the corresponding location for the live server. This step is necessary since Modx Revolution stores some paths in the database.
- zip the 'livesite' folder together with the edited database backup and ftp to your live server.
- After extracting on the live server, check that your core/config/config.inc is not writable (important!) but all directories that are required to be writable have the necessary permissions.
- Done.
With this method, you do not have to install Modx Revolution all over again on the remote server as everything you need is in the 'livesite' folder and your database copy. So far it does the job for me and I hope that it serves you equally as well.
Comments (0)
Add a new comment:
Please login to comment.