Have you ever thought that, “I will just test this module quickly” or “I will just modify this stylesheet” and you end up with more work or more problems than expected.
The proper way is to setup a clone (an exact copy) of your original shop and test the changes first. Once you know that it is working, do the same thing in the live installation.
Step 1: Create a subdomain for your test shop
In my opinion the best way to setup the testshop is to use a separate subdomain (or even a totally different domain. If your hosting provider does not allow you to create more subdomains you will have to put the test site in a normal subfolder on your server.
Creating a subdomain is simple. After logging into Plesk just go to the Websites & Domains and at the bottom of the page you will find these options:
Select “Add new subdomain” and enter the name of the new subdomain and the folder on the server where you want to put the test site. In our case we call it “perf” which means the testsite will be available in perf.givensa.com. Normally you want to name the subdomain and the folder the same.
Step 2: Copy the files we need for the prestashop clone
We will work through Plesk in this guide since it is much faster than downloading the full shop over ftp just to upload it again.
and you are taken to a confirmation screen where you need to also enter the destination directory.
Important: If you are using a subdomain, remember to remove the /httpdocs/ and just enter the folder name like in our example:
And we are done with the transfer of the Prestashop files.
Step 3: Create a new database for our Prestashop clone
Step 4: Create a user for the database
Choose a name and password for the database user. You can pick anything. For simplicity we have chosen givensa_perf to have a prefix “givensa” and a connection to the test site “perf” so we do not risk mixing it up with other databases.
Step 5: Importing the original database
Before importing anything, we would have to export the original database. How to export a database is already explained in How create a Prestashop database backup. Please refer to that article and then come back here for the next step when you are done.
and choose the database you just Exported. Click “Continue” and wait for a while for the database to be imported.
Wow thats awesome, now we have the files copied and we have a database uploaded. However the database contains some info from the live site that we need to change.
Step 6: Modifying the database to work with the Prestashop copy
and click on it.
Search on the page for the field called PS_SHOP_DOMAIN and when you find it, below you also see PS_SHOP_DOMAIN_SSL. Change both of them to the new url of the test site. In our example we will insert perf in front of the givensa.com domain name.
Step 7: Updating our database settings to match the new database
Now when we have the database imported, we must tell Prestashop which database to use. In the copy we made previously Prestashop still wants to look at the original database and this is definetely not what we want.
So, go back to Websites & Domains and click again on the File Manager. Go inside the folder of our new testsite (in our case it is /perf/) and click on the config folder and locate the file settings.inc.php and click on the pen icon to edit the file.
Change the fields DB_USER and DB_PASSWD to match the credentials we set earlier. In our case we entered givensa_perf for both. If you old settings does not say:
you will have to enter the name of the new database in that field (in our case it would be “perf”).
Now Prestashop will be able to use the correct database.
Step 8: Updating our .htaccess file
Fantastic, if you now go to your test site (in our case it is perf.givensa.com) you should see it working.
Congratulations, you have created an identical copy of your prestashop site. In order to finish up nicely, we would not like for Google to index this site so we add a robots.txt that blocks all search engines from browsing our test installation.
Add blocking robots.txt for the Prestashop test site
Go back to the File Manager in Websites & Domains and find robots.txt in your test site folder. Click on the pen to edit it. Delete all info in the file and add these lines:
Now search engines will not crawl your test site.
Now everything should be in order and you are ready to start hacking around in your test installation. I hope you find the tutorial useful and if you have any comments or found errors or things that could be more clear, do not hesitate to let me know by posting a comment below.