Jump to content

How to copy your live website prestashop 1.7.6 from server to Local / Localhost


Recommended Posts

Hi guys, 

I write the steps I followed for clonating my online shop with prestashop 1.7.6 to my local machine (localhost).

What did I use?

-  OS linux mint

- terminal shell command line and phpmyadmin

- SSH

  1. Download prestashop files from the live server

    You can do this from FTP to any folder in your machine
    I did it  in /Downloads/clon-presta-new-folder/
    (If you try to do it in /var/www/html you could have some permission problems...)
     
  2. Export database with default settings
    Best way is from phpmyadmin: export

    but if you need via SSH you can do it as follow:
    mysqldump -u dbusername -p dbname > /path/to/file/nameOfFileYouLike.sql

     

  3. Create localhost database with the same name
     
  4. Import database copy
    from your machine, open the terminal and import it as:
     
    mysql -u dbusername -p dbname < /path/to/file/file.sql

     

  5. Copy downloaded files into new location

    copy from /Downloads/clon-presta-new-folder/ to /var/www/html/prestashopFolderName
     
  6. Change database_host, database_user and database_password in:
     
    app/config/parameters.php

    You can open first your file from live shop to remember some data if you need

  7. In ps_configuration table from phpmyadmin:

    Change PS_SHOP_DOMAIN to localhost
    Change PS_SHOP_DOMAIN_SSL to localhost
    Change PS_SSL_ENABLED to 0
     
  8. In ps_shop_url:
    Change domain to localhost
    Change domain_ssl to localhost
    Change physical_uri to the PS location (mine is /prestashop/)
    don't forget slash!
     
  9. Delete .htaccess from the root folder
    better just rename it as: _,htaccess
     
  10. Disable and enable once again Friendly URLs in admin settings

    Enter to your backoffice (BO) with your URL + adminMANYNUMBERSANDLETTERS (i.e mine: dntlgfmql6vhltxy)

    After you enter, as I say, you have to change to NO and after that save. Do it again to YES and save.
    This is very importat tyo do it.

Hope none have problems.

Happy coding :D

 

Edited by Calleja (see edit history)
  • Like 4
  • Thanks 2
Link to comment
Share on other sites

  • 10 months later...

Hi,

Thank you for this, working well for me except for friendly urls.

I've disabled, saved, enabled, saved again, and it's not working.

If I try to disable friendly url, everything is working (with ugly urls ;) )

Any idea of what can be the problem ? 

[EDIT] mod_rewrite was not enabled on apache2. Everything is ok now...

Edited by Art et Tonneaux (see edit history)
Link to comment
Share on other sites

  • 2 months later...

Thanks for instructions... Something similar was doing on old version and it worked, but now have some issues ...

Presta 1.7.6.5 sitting on localhost... Can find ps_configuration table but no PS_SHOP_DOMAIN; PS_SHOP_DOMAIN_SSL etc. Preparing to move to live host from local and am a bit confused?

Maybe any suggestions?

Thanks in advance

Link to comment
Share on other sites

This is what worked for me:

  1. Create a new local DB and name it differently from your online DB,
  2. Import the full DB dump into it,
  3. Copy all your files to your localhost site root,
  4. Rename .htaccess to _.htaccess (or simply delete it) in the root of your localhost site,
  5. Go to var/ and delete the Caches folder,
  6. Using phpMyAdmin change PS_SHOP_DOMAIN and PS_SHOP_DOMAIN_SSL to localhost (or localhost:XXXX) where XXXX would be your default or custom port,
  7. Change PS_SSL_ENABLED to 0
  8. Edit app/config/parameters.php to reflect your local server settings

Worked for me using MAMP locally. I didn't have to disable/enable anything in BO. Just clear all Caches.

Edited by ecommX (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Thanks! crystal clear!

I¡ve got to access the admin in local, but when I try to access the Front it sends me to the original website instead. Is something related to having the website in 2 languages, which in this case the website needs to decide where to redirect you and then it sends me to the published website instead of the route in localhost, because when I use the localhost mentioning the /en/ in the url, it keeps me in local

Edited by omar2886
I think is something related with languages (see edit history)
Link to comment
Share on other sites

  • 4 months later...
  • 9 months later...

Hi All, 

I have done exactly what Presta_lover recommends and really close what ecommX recommend (My difference is that the new DB is called as the one working on the live website). After all these steps are done, when I try to access to back office login, the ERR_CONNECTION _REFUSED is there. 

My server is a PC set up with ubuntu server 22.04.2, Apache, MariaDB and PHP 7.3 for my Prestashop 1.7.7.2. This equipment is connected to the same router than the computers from I try to acces on the local network. 

Also, I have myphpadmin installed and correctly running with full access to the new database, and can connect to it from wevery computer in the local network.

I can´t find where is the problem. I thought it could be W11 but when I try to access from a laptop with Linux the situation is the same. Firewall is running on the server but http, httpd and all necessary ports are open and as I mentioned I can access without problem to phpmyadmin and Apache is serving virtual hosts, no Apache error logs.. 

Debug mod is active and I´m not received error messages when I try to access to back office login. I can see the route to the admin´s folder when I try to access but the result is err_connection_refused

I will follow checking, testing and trying different things... all comments will be really welcome..

Thanks in advance!

Link to comment
Share on other sites

Hi MAPH25. It was a long time since I did this but I remember that I also had the same ERR_CONNECTION _REFUSED but I can't remember in which state it happened. For some reason that I can't remember I got it working in the end.

I just opened my notes to see what I might have done. One note is to use the ip-address instead of localhost in ps_shop_url.

Here are the most important parts of my notes. I wish you good luck!

7. In ps_configuration table from phpmyadmin:

    Change PS_SHOP_DOMAIN to localhost (use ip instead)
    Change PS_SHOP_DOMAIN_SSL to localhost (use ip instead)
    Change PS_SSL_ENABLED to 0
     
    8. In ps_shop_url:
    Change domain to localhost (use ip instead)
    Change domain_ssl to localhost (use ip instead)
    Change physical_uri to the PS location (mine is /prestashop/)
    don't forget slash!
     
    9. Delete .htaccess from the root folder
    better just rename it as: _,htaccess

 

  • Like 1
Link to comment
Share on other sites

Thank you very much Gunnar.. honestly this is a madness.. 

I´ve tried using server´s IP but I will try it again. I have just created a new database named different than the original (working on live) as ecommX adviced to dischart all possibilities. 

I will try with IP also and let you know. 

Thanks!

Miguel

Link to comment
Share on other sites

2 hours ago, Gunnar said:

Hi MAPH25. It was a long time since I did this but I remember that I also had the same ERR_CONNECTION _REFUSED but I can't remember in which state it happened. For some reason that I can't remember I got it working in the end.

I just opened my notes to see what I might have done. One note is to use the ip-address instead of localhost in ps_shop_url.

Here are the most important parts of my notes. I wish you good luck!

7. In ps_configuration table from phpmyadmin:

    Change PS_SHOP_DOMAIN to localhost (use ip instead)
    Change PS_SHOP_DOMAIN_SSL to localhost (use ip instead)
    Change PS_SSL_ENABLED to 0
     
    8. In ps_shop_url:
    Change domain to localhost (use ip instead)
    Change domain_ssl to localhost (use ip instead)
    Change physical_uri to the PS location (mine is /prestashop/)
    don't forget slash!
     
    9. Delete .htaccess from the root folder
    better just rename it as: _,htaccess

 

Hi again, 

When I set my IP instead 'localhost'  i obtain the next:

[PrestaShopException]
Link to database cannot be established: SQLSTATE[HY000] [2002] Connection refused
at line 136 in file classes/db/DbPDO.php

131.     public function connect()
132.     {
133.         try {
134.             $this->link = $this->getPDO($this->server, $this->user, $this->password, $this->database, 5);
135.         } catch (PDOException $e) {
136.             throw new PrestaShopException('Link to database cannot be established: ' . $e->getMessage());
137.         }
138. 
139.         $this->link->exec('SET SESSION sql_mode = \'\'');
140. 
141.         return $this->link;
DbPDOCore->connect - [line 330 - classes/db/Db.php]
DbCore->__construct - [line 241 - classes/db/Db.php] - [4 Arguments]
DbCore::getInstance - [line 47 - config/alias.php]
pSQL - [line 1336 - classes/shop/Shop.php] - [1 Arguments]
ShopCore::findShopByHost - [line 337 - classes/shop/Shop.php] - [1 Arguments]
ShopCore::initialize - [line 118 - config/config.inc.php]
require - [line 40 - admin/index.php] - [1 Arguments]

When I set it to 'localhost' this exception dissapears.

Puting special attention to phpMyAdmin: to access, I input 'http://192.168.1.39/phpmyadmin' on EGDE explorer and I get the login access window. After I log in, in the label of the explorer´s tab I can read '192.168.1.39/localhost | phpMyAdmin 5.2.1'  . In the explorer´s address bar is displayed '192.168.1.39/phpmyadmin/index.php?route=/&route=%2F'

So I understand that 'localhost' is the correct one on my situation... but still having the ERR_CONNECTION_REFUSED problem... 

Spin, spin, spin.... the black circle.. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...