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

Drupal-move-from-github

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)

Link to Gitpod.io / GitHub repository

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:

  1. A site ready to be transferred at gitpod.io
  2. 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.
  3. A fresh domain/sub-domain, an empty database (usually MySQL) and a way to access them – usually CPanel.
  4. 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:

  1. 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
  2. Install the Backup and Migrate module
    composer require drupal/backup_migrate
    drush en backup_migrate
  3. Use Backup and Migrate to backup the database and public directory (download these to your computer).
    1. Go to Configuration->Development->Backup and Migrate->Backup->Quick Backup.
    2. Select Default Drupal Database and the Download option (these are the defaults).
    3. Click Backup Now.
    4. The database will be compressed and downloaded. This should be fairly quick.
    5. Change the Backup Source to Public Files Directory and click Backup Now. If you have a lot of files, this might take some time.
    6. If you have Private Files change the Backup Source to Private Files Directory and click Backup Now.
      backup and migrate main screen

  4. 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.
  5. 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.
  6. Make sure your public_html (or root web directory) is completely empty.
  7. 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.
  8. 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.
  9. Install and enable ALL the modules from the gitpod site (including Core Modules)
    1. using composer and drush (if available)
    2. 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.
  10. If you have custom modules repeat the above : tar -czvf mods.tar.gz custom
  11. Restore Database using Backup/Migrate. On your new live site, head over to Configuration->Development->Backup and Migrate->Restore. Upload your database.
  12. Restore Public Files
  13. 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.
  14. Clear cache from the terminal: drush cr or go to: Configuration->Development->Performance->Clear all caches.
  15. 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

Author

  • Rod Martin

    Rod holds two masters degrees and has been training people how to do "things" for over 25 years. Originally from Australia, he grew up in Canada and now resides just outside Cincinnati, Ohio. He has worked in both the non-profit and for-profit worlds, in small companies and large corporations. His extensive open source experience includes WordPress, Joomla and Drupal and he really knows how to help you get the most out of the system you chose. Rod plays ice hockey a couple of times a week and rides his Goldwing motorcycle pretty much everywhere he can.

0 0 votes
Article Rating
Subscribe
Notify of
6 Comments
Oldest
Newest
Inline Feedbacks
View all comments
nstocco
1 year ago

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!

nstocco
6 months ago
Reply to  imrodmartin

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.

jon-edmund-vikan
1 year ago

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

6
0
Would love your thoughts, please comment.x
()
x