How To Move a Drupal Site From Gitpod.io To A Live Server

Our Drupal 9 Explained course is move effective when every student does the work along with the videos. Currently, if someone doesn’t have a Drupal environment to practice on, we recommend a Github repository that creates a site at Gitpod.io (https://github.com/imrodmartin/ddev-gitpod).
This repository is a one-click installation of DDEV, Composer, Drush and Drupal 9 (at the time of this writing). It’s really an amazing environment that helps students learn Composer, Drush and Drupal along with our course and it’s completely free! (watch installation video at the link above)

But how can I move the site I build to a live server?
It’s really great to be able to build sites where no-one can see them until they’re ready! However, when you ARE ready, moving a Drupal site isn’t all that straightforward!
What you’ll need:
- A site ready to be transferred at gitpod.io
- SSH or Terminal access at the web host you want to move the site to (We’ll be using HiVelocity as our web host for this tutorial). If you’re on a shared host such as GoDaddy etc, you won’t be able to move your Drupal site via this tutorial. Access to Composer is required.
- A fresh domain/sub-domain, an empty database (usually MySQL) and a way to access them – usually CPanel.
- It’s beyond the scope of this tutorial to explain setting up domains, sub-domains, databases and all the things you’ll need at your live server. If you have questions, please contact your host: hosting environments can be very different one to another.
(If you’d rather watch a video of the following steps – head to the bottom of this post.)
The Steps:
- Make sure the current site and all projects are up-to-date. Head over to Reports->Available Updates to determine if your site is completely current. If it’s not, use the following commands to update your site.
ddev ssh
composer update "drupal/*" --with-all-dependencies
drush updatedb
drush cr - Install the Backup and Migrate module
composer require drupal/backup_migrate
drush en backup_migrate - Use Backup and Migrate to backup the database and public directory (download these to your computer).
- Go to Configuration->Development->Backup and Migrate->Backup->Quick Backup.
- Select Default Drupal Database and the Download option (these are the defaults).
- Click Backup Now.
- The database will be compressed and downloaded. This should be fairly quick.
- Change the Backup Source to Public Files Directory and click Backup Now. If you have a lot of files, this might take some time.
- If you have Private Files change the Backup Source to Private Files Directory and click Backup Now.
- Head over to your live web host and create a new database. Make sure you record the database, database user and password, you’ll need these later.
- Open a terminal window (in CPanel this should be available if you have enough access. If you don’t, you’ll need to request it from your web host before you proceed.
- Make sure your public_html (or root web directory) is completely empty.
- Create a new Drupal site:
composer create-project drupal/recommended-project public_html
.
(replace public_html with the name of your root web folder). This will install Drupal in the root of your website inside a “web” folder. - In your browser, navigate to the site folder and complete the Drupal site setup in the UI. This is where you’ll need the new database information.
- Install and enable ALL the modules from the gitpod site (including Core Modules)
- using composer and drush (if available)
- OR create a tar file of the modules from Gitpod.io, upload, expand, then enable with drush or the UI. On your Gitpod site, navigate to the modules folder in the terminal window and execute
tar -czvf mods.tar.gz contrib
. Download the tar file, upload it to your live server and expand it in the /modules folder.
- If you have custom modules repeat the above :
tar -czvf mods.tar.gz custom
- Restore Database using Backup/Migrate. On your new live site, head over to Configuration->Development->Backup and Migrate->Restore. Upload your database.
- Restore Public Files
- If you’re using a custom theme on your Gitpod site, head back to the terminal, go to the Themes directory and compress the theme. ie: tar -czvf theme.tar.gz name_of_theme (replace name_of_theme). Download this file and upload it to the themes directory on your live server.
- Clear cache from the terminal:
drush cr
or go to: Configuration->Development->Performance->Clear all caches. - IMPORTANT: if you used admin/admin as your user on the gitpod site – you should definitely update both: People->edit user 1->enter the current password, change the username and provide a secure password.
If you used the web directory, you’ll need to update the root of your website to point to the web folder.
This is definitely not a quick solution – there just isn’t one! Please comment below with any suggestions or changes that would make this more efficient!
Video:
Additional Resources:
System requirements for Drupal:
https://www.drupal.org/docs/system-requirements
Using Composer to Install Drupal and Manage Dependencies: https://www.drupal.org/docs/develop/using-composer/manage-dependencies
How to create tar / zip files:
https://www.hostinger.com/tutorials/how-to-extract-or-make-archives-via-ssh/
How to manually install Drush on a Webserver
https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/drupal2/installing-drush-manually
This article is very useful! Gitpod is a game changer.
Let’s assume I have my site live in a web server and my development site in gitpod and I have made a new section in my dev site. Meanwhile in the live site I have also modified pages. Which is the method you suggest to deploy the new section in the live server without losing the modified pages?
Thank you Rod, you rock!
Thanks for your kind comment. Gitpod is definitely a game changer!
So you’re now talking about the difference between Configuration Entities and Content Entities. You can synchronize configurations between sites, but not content.
Take a look under Configuration -> Development -> Configuration Synchronization (admin/config/development/configuration/full/export). You can export things like Content Types (but not content), Vocabularies (but not terms), Views etc. This is why I always use Devel on a dev/test site and not waste time creating real content.
Then import them on your production site.
There’s more information at https://www.drupal.org/docs/configuration-management/managing-your-sites-configuration. Definitely something you want to practice a bit first – start with a simple export (I usually do a view) and import – them move on to bigger ones.
Hope that helps
OK now let’s suppose that after a week I have to add a module to my site, or to change a theme file. So I need to synchronize my codebase modifications from the dev environment (gitpod) into the live server. I think that the best way is using the versioning system aka GIT, is that right? But which commands should i use to update the live server codebase with the dev one? Thanks.
Hey nstocco – that’s the subject for an entire course :). Yes – the best practice is to use Git versioning and tie the two into it. Here’s the official docs on it – https://www.drupal.org/docs/installing-drupal/building-a-drupal-site-with-git. If there was enough interest we could create a course – but currently I think it’s pretty niche on OST. I’ll see what I can do.
Thankyou Rod. I’ve been waiting so long for this, searching for a tutoral like this in every posible corners online and in forums all over the net. I cant understand why there is so little out there about this, it’s not a straight forward thing and for people like me who are not a computer genus it’s hard to figure out all steps here. You deserve a huge thanks for doing this, and I hope you keep up your good work with making tutorals here. Best regards JON
Hi Jon,
thanks for your kind words!
Yeah – it’s pretty amazing there’s not much more. It’s still a new tech so hopefully more coming. I have a couple more tutorials coming on this over the next bit…
Rod
I learned a lot from the Layout Builder for the Ambitious Site Builder course. Thank you so much for such an informative and useful class.
I am not interested in using Gitpod to develop sites, but I am interested in your Starter Site. Do you happen to have a GitHub repository with the Starter Site?
Hi Paul, unfortunately, no. You can spin one up by going to https://rodsurl.com/startersite – but this will just open it in your gitpod account. I’m looking into it – and I’ll post here if I find a quick way of doing it…