HowTo clone an existing Joomla site into a subdirectory or onto another domain
Tutorials June 19, 2009
This post is about cloning – copying – and not transferring.
Usually you develop a site either on an external staging server or a sub-domain on the same server and once ready to launch you move everything to the right place, adjust some configuration settings and you are all done. But what to do when the site already is live and in use and the client now request a duplicate site to work on larger changes and wants to see and approve everything before going truly live with those?
Cloning is the answer.
This setup will step through such a situation of using the cPanel and Fantastico while using a subdomain.
There are different options where to put the subdomain: same level as the Joomla install but in its own folder or a sub-directory within the main site such as /public_html/subdomain but outside of the current Joomla directory or outside of the public_html directory all together in /subdomain. I strongly suggest in keeping everything on the server within public_html for safety reasons.
- Once the location has been determined, go within the cPanel to the BACKUP section. Download from MySQL Database Backup the Joomla database.
At this point you could download the full Home Directory from its Backup section as a .zip file and you will need to do this if your clone will be in a different location than within the existing domain. But, for our purposes it is not needed, we will be copying the files on server level – not only will copying the files in the File Manager save time but also bandwidth.
- Install Joomla via the Fantastico panel into the subdomain – once done you will see the following or similar information in Fantastico:
/home/domain/public_html/subdomain/configuration.php configured
/home/domain/public_html/subdomain/data.sql configuredGo visit this fresh install and ensure all is working correctly. Note the URL when hovering over the HOME link: it will show as http://subdomain.domain.com if you installed it into the root of the subdomain.
-
Now you want to copy all needed files into the new directory, such us custom created media file folders and template folders, next to components and modules etc. – this can be a bit tricky and get messy if you’re trying to copy older stuff into a newer installation (clean install of components and modules is usually recommended).
Having customized plugins and components, it was out of question for me trying to fill in from one to the other installation. On top of it, this new install was at 1.5.11 (via Fantastico) while the current, live site was only at 1.5.8 and non-Fantastico installed. I decided this would be a good opportunity to upgrade the older site in the process of cloning.
To simplify the process delete everything – except configuration.php, fantastico_fileslist.txt and fantversion.php – within the new (subdomain) Joomla install. Ensure you have only these 3 files remaining in the new directory.
You should download these 3 files to the local desktop as a backup.
Then copy all files from the live site to the new site directory, except for the configuration.php file. As the old site was non-Fantastico there was no worries of overwriting such files on the new subdomain.
- Change the 1.5.11 in the fantversion.php file of the subdomain to what the old install was (1.5.8). This will allow us to upgrade the subdomain site to the latest Joomla version via Fantastico. In the future when we move this updated subdomain back into the current live one we can then also upgrade and convert the current site to a Fantastico controlled site – this will be easier for later updates.
- You will need to adjust the .htaccess file for the new subdomain and also edit the configuration.php file. These are the 2 files to modify and most important. This tutorial assumes that you have rewrite enabled in your Joomla install (for pretty URLs etc.). If you can, open the old and new configuration.php file next to each other, compare and adjust as needed. I will not go here into details as you should be at least an intermediate developer when attempting meddling on this level and to do such a clone and in this case you know what to look out for (if not, leave me a comment and I’ll elaborate).
- Insert the downloaded database into the subdomains database. For clean import first drop the content of the Fantastico generated database – do not delete the db, just drop the content [go into database, select all, with selected: drop, confirm you really want to drop] – and then import [import, locate text file to import, select the domain.sql.gz backup file, click 'go'].
At this point you are mostly done. Deep sigh. But don’t breakout the Champagne quiet yet!
Test your cloned installation.
Chances are everything is working fine at this point. It ‘should’ all be fine if you followed the outline above. If you do find problems, check that your configuration.php and .htaccess files truly reflect the new location (subdomain) and database. After that ensure that directories in the new installation have correct CHMOD settings. In my example, our old server needed 755 settings on folders, the new server automatically set them to 777 – if you are having write problems, check in this area if it’s causing you problems.
You have now a cloned, (older) Joomla site in a Fantastico environment – now lets get this updated to the latest Joomla version! Click onto Fantastico and voila! Right there it will let you know that your version is outdated. Click to Upgrade (in this case to 1.5.11).
Before closing Fantastico, ensure to save the information on how to restore if something has gone wrong. It will be a step by step instruction on how to revert this last update and look something like this:
- delete all the files listed in /home/domain/public_html/subdomain.com/fantastico_fileslist.txt
- delete /home/domain/public_html/subdomain.com/fantastico_fileslist.txt
- Untar /home/domain/fantastico_backups/.backup.124546789123.tgz
- Empty the database domain_jo123
- Import the file /home/domain/fantastico_backups//backup.sql into the database domain_jo123
- Move /home/domain/fantastico_backups/ to /home/domain/public_html/subdomain.com
Once you ensured that all is working fine you are done. In the future you pretty much only have to invert the process to move data from the staging server to the live server and you’re all set.
Hi, Very good article its really going to help a lot of newbies….
Love this!
you guys rock!
Didn’t work for me….when I go to the administrator page it says “No Input file specified”. How do I fix this????
At which point of the procedure are you trying to do this?
Did you follow each former step or did you try to short cut any?
I did every step listed. When I looked to see if it worked…the front end of the site was fine. When I went to the administrator page…that’s when I had the error. I’ve been googling it and trying to find a solution but nothing so far.
Hello again. I figured it out! Thanks for the prompt response though! Love this article!
Great Roco – I just saw your comment that you figured it out. Glad to hear!
I don’t quite understand why we would start with a new install and then copy files over it. Why wouldn’t you simply copy the current files to the new directory and adjust the configuration files mentioned above? Then, if you want to upgrade, you simply do that on the new site.
Or is the link to Fantastico driving the need to have the duplicate site installed by Fantastico? Ah, yes, that must be it.
Now, I really would like to know how to bring back the developments onto the old site: I assume we are going to copy the files over the old, live site, but what about the database? How do we bring in new tables etc. into the old site, which now contains new content? Is the approach to identify manually each new table for modules etc. and copy that over individually?
Hi Ruedi -
This approach describes a very specific situation. Yes, as you realized, an important aspect was to go via Fantastico to make it easier on the client at a later stage to update via it.
Not clear what you mean by ‘bring back into the old site’. Which site do you now consider ‘the old site’?
In the above example the live site was first, then we made a clone of that in a subdirectory. Now it’s up to you (and/or the client) to make all new changes to the clone – the one in the subdirectory, as this is the whole purpose of having that clone: it’s the development site. While the live site is there , you can add things to the clone in the subdirectory and when happy you update the main site with the clone (the subdirectory).
Is your question on how to regularly update the live site with the modified clone from the subdirectory?
Hi, I liked your article, and I am a really newbie so I need some help with htaccess and configuration.php files (as you mentioned above, I don´t want to mess everything up). I would also like to know how to use my clone to update the live site, sorry if it seems obvious, but I don´t know how. Should I install the component, module or plugin on live site, and then copy the database and upload it to live site with phpMyAdmin? Thanks.
Hi Alejandra – I do feel you should be somewhat comfortable manipulating the htaccess and config.php files before attempting this stuff. Maybe do a Google search for some simple tutorials on how to use and/or modify .htaccess files. Then, compare your clone and your live site configuration files and study the difference. When I personally have to make my clone to go live, I usually delete everything but the htaccess and config file in the live site and copy-move everything but those 2 files from the clone to the live site. Then I drop the tables in the database from the live site and import the data from the clone. That usually does it for me. I suggest you look for some in depth tutorials if this is not clear for you. Good luck!
Hi,
I cloned my joomla site from root to sub domain, everything else seems to be working fine but virtuemart. In joomla administration area when I go to virtuemart section, it shows teh summary page and from there when I click on any virtuemart option it redirects me to frontpage. What could be wrong? Would really appreciate the help.
before cloning joomla version: 1.5.18
current joomla version: 1.5.21
virtuemart version: 1.1.4
I am a newbie and really struggled with figuring out why I was not able to clone the database properly (was getting database already exists error). Turns out it was really simple, in phpmyadmin export tab unselect comments.
Hello everybody, please i have just uploaded my site to my host after i have configured the configuration.php file in my joomla folder it works fine but when i try to login to back end it says administrator was not fund on this server. please i don’t no what to do i need your help thanks.
If you can not log in it means that the database does not have the user. If you have moved everything and the site looks good on the front-end at the new location the users it would mean that the user data has moved too with the database and should be available too. The config file contains data for the database, the login data will be stored in the database.
Great tutorial. Worked beautifully. Thanks a million!!!
Hi,
We have cloned the joomla site to a different server. Everything on both servers look the same. However, I cannot see the site on the separate location. The database on both servers have the same name, password etc. trying to access the one on the new server using ip address gives error 404 Component not found.
Please assist.
I am sorry – at this point it has been too long for me – I specialize in WordPress – to easily assist you. The only thing I can suggest is that you go over my points listed step by step and ensure that you followed them precisely. ESPECIALLY “If you do find problems, check that your configuration.php and .htaccess files truly reflect the new location (subdomain) and database.” Best of luck.