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.
In the same Website & Domains, click on File Manager:
and if your Prestashop is installed in the default httpdocs folder, click on that folder and you will see a long list of the Prestashop files.
Important: Now we must select all files. Find the word “All” to the right on top of the file list and click it.
Now all files are shown on one page. Select the checkbox to the left in the file manager header:
Now all files and folders are selected and the file list looks like this:
Click the Copy/Move button:
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 when it has completed you will return to the FileManager with a success message.
And we are done with the transfer of the Prestashop files.
Step 3: Create a new database for our Prestashop clone
Go back to Websites & Domains and click on the Databases icon.
Choose “Add new database”
In the next screen just give the database a proper name. We have chosen “perf” to match the name of the subdomain.
Step 4: Create a user for the database
Now just click on the “add new database user” icon.
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.
Now ensure that you are back at the page with your newly created database (in our case the one called perf). Then click “Webadmin”
and you will enter the phpMyAdmin tool which allows us to import an existing database. In the menu there are not so many options at this time. Simply click “Import”
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
One the left side find the table called ps_configuration
and click on it.
Change the Number of Rows field to show 3000 instead of 30 and press Enter so we can easily search the whole database.
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.
If your prestashop version is 1.5 or higher. You also need to find the table called ps_shop_url and make the same changes so it looks something like this:
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
In order for things to work we must regenerate the .htaccess. This we do from the Prestashop admin interface so go to http://yoursite.com/admin and under the Preferences tab select SEO & URLs.
In order to make Prestashop rewrite the .htaccess file, all you have to do is click the Save button.
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.