Copy Drupal site from live server to localhost
Copy Drupal site from live server to localhost
In this example, we are using xampp in localhost. This is the step:-
In live server
1) Activate maintenance mode | Configuration->Development->Maintenance Mode and will disable the site
2) Delete Drupal Cache | Configuration->Development->Performance
3) Copy the database from live server | using export
4) Copy the code from live server | using FTP
In localhost
1) Create the database
2) Import the database from backup | read how to import large database
3) Change setting.php file
From live server setting:-
$settings['trusted_host_patterns'] = [
'^mydomain\.com$',
'^www\.mydomain\.com$',
];
Change to:
$settings['trusted_host_patterns'] = [ '^localhost$', ];
4) Change the database setting
From live server setting
$databases['default']['default'] = array (
'database' => 'drupal_db',
'username' => 'user',
'password' => 'password',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
Change to | in localhost (xampp) - username is root & no password
$databases['default']['default'] = array (
'database' => 'drupal_db',
'username' => 'root',
'password' => '',
'prefix' => '',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
5) Remove the real domain HTTPS configuration to work in HTTP mode.
In case we have SSL enabled in our production server, we will have to remove the lines that allow us to redirect HTTP to HTTPS in .htaccess file.
# RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-Proto} !https
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
6) Run update.php
Read more:-
- https://www.youtube.com/watch?v=fWy8clD4vL8
- https://rainnic.altervista.org/en/copy-drupal-remote-to-local?language_content_entity=en
- https://wishdesk.com/blog/move-drupal-website-another-host
- https://www.liquidweb.com/kb/clone-drupal-site-to-another-domain/
- https://fbalaguer.com/en/article/drupal-migration-production-local-testing-server
client = ca-pub-2898279488603899
slot = 9058461004
format = auto