Synchronizing Local and Production Sites - Drupal
You’ve built a Drupal 8 site and want to host it on your server
or
You’ve set up a Drupal 8 site on your remote server and want to work on it locally
Drupal 8 is Different
Up until Drupal 7, it was a relatively simple process: copy all the files, copy the database, and you're good to go.
With Drupal 8, CMI – Configuration Management Interface – comes into play and must be handled appropriately.
How to Synchronize Your Site
The process is the same whether you're mirroring your site from local to server or the other way around. I’ll describe deployment from local to remote server for simplicity.
1. Install your site on a local web server like WAMP, XAMPP, MAMP, or any server stack of your choice.
2. Move all files from your Drupal directory to the server. You can do this using version control (Git, SVN, etc.) or FTP.
3. Do not copy the settings.php
file located inside sites/default
.
4. Create a new database on your remote server and perform a fresh Drupal installation.
5. Export your configuration from your local site at /admin/config/development/configuration/full/export
.
6. Import the resulting config.tar.gz
file via /admin/config/development/configuration/full/import
on your remote site.
7. Export your database from your local web server using PHPMyAdmin or another tool. The recommended Drupal module for this is Backup and Migrate.
8. Import the database to your remote Drupal 8 site using the same tool.
9. Voilà! Everything should now be synchronized. If you’re not syncing content such as nodes or users, you may rely solely on the config.tar.gz
file from CMI for synchronization. However, if you're unsure or new to Drupal, always synchronize the database too for full consistency.
Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.