When you run a webshop, uptime is one of the most important factors. If your shop is down, you are not able to take any orders and in the end you will loose money. But it is also important to develop the page, and make new features. If there is no evolution in the website or it don’t follow the new features that are the trend at the internet, people will not trust your shop and in the end not buy from you.
But developing at a live website is a very bad idea. You will present unfinished work to your customers and maybe even break the site. Therefore, always make development at a separate page.
For one of my shops I use Prestashop, therefore I will in this blog post show, how to make a complete copy of the live Prestashop, that is totally set apart from the live shop. Therefore you can create orders and everything, without getting trouble with the government.
Our shop is run at Hosting4Real, and they use cPanel for the platform of hosting. Therefore this guide will be on how to duplicate the shop in cPanel.
So, let the madness begin!
The first thing we will do is creating a subdomain, that you can use for the dev site. This way the developer site is totally of the site, and a customer would probably never visit the site by a mistake. Open your cPanel and click the Subdomains button.
Put in the information about the site, that you want. For my purpose I choose to have the subdomain named dev.domain.dk. This way I could easily invite others to check my development and comment the design etc. By default cPanel only puts the name of the subdomain into the document root folder, but I really like to have the rest of the domain implemented in the folder name. This way I can easily see, what is a part of the root website, and what is subdomains. When done, hit save and go back to the home of cPanel.
We will now copy all of the files of the original shop to the folder of our newly created subdomain. You can do this by using a normal FTP connection and transfer them between the folders. But in my opinion it is easier to copy these files using the built-in file manager from cPanel. This way you will just make the server work, and not transfer the files away from the server. So back at the homepage of cPanel, choose File Manager.
cPanel will ask you what folder you would like to access. You could choose to access the subdomain we have just created, but to be able to copy the files between the root folder and a subfolder, we will just choose the web root.
Now you are in the root folder of your root domain. Mark all files in the root that is associated to the Prestashop. This means that you should not mark any subdomain folder or anything like that. When all files you want to copy is marked, go to the button called Copy.
cPanel will now ask you where to put the files you have marked. Put in the folder name you created like on the example in the screenshot below.
The files is now copied and we will go to the MySQL application in cPanel and create a database.
Put in the name of the wished MySQL database and click create.
Now, scroll a little down on the page until you find the area called “Add New User”.
Create a new user for the developer site and click Create User.
The last thing we will do in this menu is to assign access to that specific database to the user you just created. Scroll even further down and find the “Add User To Database”.
The system will now ask which privileges to assign to the account. I select all here.
So now, we will go to the application called phpMyAdmin. You find this at the MySQL tab in the home of cPanel.
Inside phpMyAdmin we will now copy the database from the original site into the newly created database, which we will use for the development site.
Inside phpMyAdmin, now select the database that you currently use for your shop.
When selected, go up in the top and select the Export button.
phpMyAdmin will now ask how you want to export your database. As you are not going to use the export for anything else than a import, it is the easiest way to choose Quick and SQL like below:
After this, go and select the newly created database you want to use for the development site. When you have the database selected you should select the import tab.
phpMyAdmin will ask for the SQL file you just created and downloaded. Go and select this and click Go.
When done, you should get a green line in the top saying that the import was successful.
We now got a complete copy of the database as it is right now. This means that everything is a mirror of the live shop until a customer has ordered a new order. New orders or any changes in settings will not be replicated as this is a separate database to be sure, that you don’t mess up with your customers or their data.
To have the shop to know where to look for the database, we will need to edit the config file of Prestashop. This ensures that it will look into the new developer database instead of the old live version.
The config file is found in the folder config and is named settings.inc.php. For my developer site the URL is now public_html/dev.site.com/config/settings.inc.php.
Inside the config file there are several things we will need to change. The first thing to be aware of is if you use Media servers or CDN networks for your static files at the shop. If you do so, you have to delete the servers from the config file. The developer site will not work with these.
Furthermore you will have to add the new database informations as shown on the screenshot below.
Now the last thing we will need to do is to edit the site URL of the developer site. This way it wont just redirect to the mother site every time you try to load it.
This is done three places in the database.
The easiest thing is to start out with a search in phpMyAdmin. So go ahead and select your developer database and click the Search tab. Search for PS_SHOP_DOMAIN.
phpMyAdmin will now find the row with the searched text and show it to you. Click the edit button.
Put in the new URL for the shop and hit Go.
Go and find a table called ps_shop_url and edit the two URLs here too.
The very last thing we need to do is to copy the .htaccess file from the original shop folder to the developer. File Manager does not do this, so just copy the files with your FTP client.
That’s all, you should now have a fully working copy of your live Prestashop. A little tip to be sure that no customer reaches the site, would be to put on a password and maybe add a little banner in the header file saying that this is a developer site and no orders are sent – Just in case.