May 14, 2012

f Comment

Create a Separate Copy of a Joomla Website in Minutes!

First take a look at my Joomla version
Amazon The following is information shown by going to Site -> System Information.

PHP Built OnLinux ip-10-1-2-3 4.5.6-7-ec2 #18-Ubuntu SMP Mon Oct 18 21:00:20 UTC 2010 i686
Database Version5.1.61-0ubuntu0.10.04.1
Database Collationutf8_general_ci
PHP Version5.3.2-1ubuntu4.14
Web ServerApache/2.2.14 (Ubuntu)
WebServer to PHP Interfaceapache2handler
Joomla! VersionJoomla! 2.5.4 Stable [ Ember ] 2-April-2012 14:00 GMT
Joomla! Platform VersionJoomla Platform 11.4.0 Stable [ Brian Kernighan ] 03-Jan-2012 00:00 GMT
User AgentMozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19

As you can see I use Joomla 2.5.4, but this tutorial applies to every previous version of Joomla. If not let me know!

The Problem
Suppose you have a Joomla site running and you want to create a copy of it so that you can modify the copy and use it as a demo website for your new customers. What do you need to do? Do you simply copy the installation files to a new folder and that's it? Do you need to do anything weird to the database? I've figured out the steps. All you need to do is follow the following easy steps and you will create a separate copy of your Joomla website in MINUTES!

The goal is to create a independent duplicate of an existing Joomla site so that modifying one site does NOT affect the other and vice versa!
Step 1: Create a New Folder
First you need to create a new folder to put the duplicate Joomla files in. Suppose your original Joomla site's folder is /home/ubuntu/repository/joomla/MyFashionWebsite/. Your new folder can be /home/ubuntu/repository/joomla/Demo/ if you are creating a copy for demonstrating purposes.

Step 2: Copy & Paste & Set Permissions Properly
Continuing with the examples above, copy all files from /home/ubuntu/repository/joomla/MyFashionWebsite/ to /home/ubuntu/repository/joomla/Demo/. A caveat is you need to copy ALL files including special files such as files with names following a dot. One such file is the .htaccess. This file is a MUST if you enable SEO's URL rewriting in Site -> Global Configuration.

Then you should set permissions of Demo/ correctly. Essentially you can set the owner:group of everything in Demo folder to www-data assuming www-data is the user name that runs your web server process.

Here's the Unix commands that do both Step 1 and Step 2:

cd /home/ubuntu/repository/joomla
cp -r MyFashionWebsite Demo
sudo chown -R www-data:www-data Demo

'-r' and '-R' means recursive. Isn't it bad that different Unix command may use different option letters to indicate recursive operation?

Step 3: Create a New Database
You need a new database to hold the database tables for the new site. If you use PhpMyAdmin you can easily create a new database in their user friendly UI. If not then run your MySQL client and issue this command to create a database called 'demo':

create database demo
Step 4: Duplicate Database & Database Tables
Copy all your tables from the old database to the new database. In PhpMyAdmin simply export the entire old database and import it into the new database. It'll just take a few seconds.

Step 5: Correct configuration.php
This is the MOST IMPORTANT step!
We've basically created a separate copy of Joomla files and Joomla database tables. Now all we need to do is correct Joomla's configurations. In your Joomla's root folder open configuration.php and make these changes:

-Find $db and change its value to 'demo' or whatever your new database name is.

-Find $sitename and change its value to your new site's name

-Change all other relevant variables such as $fromname which specifies the Mail From if you use Joomla to email people, $mailfrom which specifies the From email whenever you use Joomla to send emails, $MetaDesc which specifies the text used in meta description HTML tag, $log_path and $tmp_path because your logs/ and tmp/ folder live in /home/ubuntu/repository/joomla/Demo/ now.

In case you get a more advanced Joomla version, you probably want do a global search at /home/ubuntu/repository/joomla/Demo/ for the old site's name and correct them if applicable. Suppose your old site's name is 'FashionSite' run "grep -R FashionSite *" and walk through every match and correct as necessary until you are done.

Now open a browser and go to the URL that points to the new folder and you should be able to see a brand new Joomla site, which is COMPLETELY separated from the old Joomla site. Now you can modify this new site without affecting the old site AT ALL. Have fun!

Sometimes you need to dig deeper when you get an error while browsing the duplicate Joomla site, especially when your original Joomla site has many third party components, modules, or plugins installed on it.
For example I am using Fabrik, a popular component for making custom made HTML forms. After I create a copy of the Joomla site that uses Fabrik I can no longer submit form data or view submitted forms in the database via the administration panel.

The reason is 'j_fabrik_connections' table needs to be updated with correct database credentials if you are using different username or/and password in the duplicate site's database.

Also 'j_fabrik_elements' somehow got two new columns added, 'id' and 'date_time', at some point during the installation process. This fact creates an SQL issue when I submit a form. I removed the duplicate columns and everything started working again.

Any questions? Let me know!

Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael