Note: This post assumes your server is powered by WHM/cPanel and that you have ssh access. If you’re using Plesk then you can still do the below with minor modifications. As usual, you can contact us for help.
Warning: While we try our best to make our guides as easy as possible, we have to warn you: any mistake here can potentially wipe out your whole website (both production and development). Make sure you proceed very carefully and make sure you give this job to a system administrator if you’re not sure what you’re doing.
If we had a dime for every time we moved a Joomla website from development to production, we’d be ultra rich. We do this nearly every day – and sometimes several times a day. We have reached a point where we know the process by heart. In case you want to do it yourself, here’s how it’s done.
-
Connect to your server through ssh
You can use a tool like Putty to connect to your server’s shell. You don’t have to connect as root but usually this makes the job easier.
-
Change to your website’s main directory
Issue the following command:
cd /home/[your-user]/
(if you’re logged in as root)or
cd /
(if you’re logged in as the website’s user) -
Create a temporary folder where both the production and the development websites will be moved into
Issue the following commands:
mkdir old
mkdir new
The first directory will hold the current production website, and the second directory will hold the current development website.
-
Move the development website to the “new” directory
Assuming that the development website exists under /home/[your-user]/public_html/v2/, issue the following command:
mv /home/[your-user]/public_html/v2/ /home/[your-user]/new/
(if you’re logged in as root)or
mv /public_html/v2 /new/
(if you’re logged in as the website’s user) -
Move the production website to the “old” directory
Issue the following command:
mv /home/[your-user]/public_html/* /home/[your-user]/old/
(if you’re logged in as root)or
mv /public_html/* /old/
(if you’re logged in as the website’s user) -
Move the development website into production
Issue the following command:
mv /home/[your-user]/new/* /home/[your-user]/public_html/
(if you’re logged in as root)or
mv /new/* /public_html/
(if you’re logged in as the website’s user) -
Rename htaccess.txt to .htaccess
A quick note before doing the below. Unfortunately, the Linux mv command does not move hidden files by default (the htaccess file is typically a hidden file), so what you need to do is to first explicity move/delete the old .htaccess that is still residing in the public_html directory.
While under the public_html directory, issue the following command:
mv htaccess.txt .htaccess
-
Fix the configuration.php file
The configuration.php in the new website most likely now contains incorrect log and tmp values. If your development website was running under a v2 folder, then make sure you trim that /v2 from the values of the $log_path and $tmp_path global variables.
-
Ensure that all the permissions are correct
Make sure that you’re giving Apache write permissions only to where it should be able to write. E.g. the cache folder, the images folder, the logs folder, and the tmp folder. Note also that some components may require write access to some specific directories inside the components or administrator/components folder (sh404SEF is one example, VirtueMart is another example).
-
Backup your current production website
Just issue the following simple command to backup the website:
cp -R /home/[your-user]/public_html/* /home/[your-user]/new/ (if you’re logged in as root)
or
cp -R /public_html/* /new/ (if you’re logged in as the website’s user)
Note that the above step can take some time if you’re running a huge website. Also note that the above will not backup your database – your database can be easily backed up using phpMyAdmin.
-
Congratulate yourself on a job well done
Now sit back and relax – your development website has replaced production, and your visitors are now enjoying a (hopefully) better, more reliable website.
Now, in case you’re experiencing a hiccup anywhere in the process above, then we urge you to contact us. We’ll definitely solve the problem for you, we’ll charge you a very reasonable fee, and we’ll do it for you very, very quickly.
[…] a month ago, we discussed how to quickly move a Joomla website from development to production. The process that we described in that post always worked for us – until yesterday. […]