Installing the Site on a Production Server with Composer

Now, we're ready to install the site on the remote server so that we can start moving code and config changes between two instances of the site.

Note: Make sure you add your server's ssh keys to your GitHub/BitBucket account so that it can pull your repo.

First, I'll ssh into my server, then move into the directory containing my web root (in my case that's public_html). From there, I'll remove the existing site and clone the new site repo into the directory.

  • SSH into the server
  • cd public_html
  • mv drupal drupal.original (Because I installed this site with a "one-click" type installation, I just need to get rid of the existing site. However, I'll need to keep the settings.php file to copy the database settings to my new site.)

Clone the repo

git clone

This will clone the repo into a directory named "drupal8site".

My particular host expects the site to be in the directory "~/public_html/drupal", but you might remember that my project root is not the web root, so I can't just rename the "drupal8site" directory to "drupal". Instead, I'm going to create a symlink from "drupal" to the "drupal8site/web" directory in my git repo.

If you usually create the vhosts file yourself, you can simply point to the web directory. But, since I used a "one-click" type installation, I need to use this workaround.

  • ln -s drupal8site/web drupal Creates a symbolic link at "drupal" that points to "drupal8site/web"

Run Composer Install --no-dev

Now, let's move into the project directory and run the composer install command to build out the site.

cd drupal8site
composer install --no-dev

You'll notice that this time, I'm running composer install with the --no-dev modifier. This will run the composer install process (using the composer.lock file) and install everything in the "require" section, ignoring the "require-dev" section.

This means things like Behat, phpunit, and even modules in that section like devel, stage_file_proxy or reroute_email that should really only be on dev servers won't even be downloaded to the production server.

Configure Database

Now, let's create a settings.local.php file that will contain production-specific information.

First, I'll copy the database credentials from the site that was installed when I used the one-click install method on my server, so that I can paste them into my new site.

Copy original database credentials

  • vi ../drupal.original/sites/default/settings.php
  • Find the database credentials and copy them

Paste the Database Credentials into settings.local.php

  • vi web/sites/default/settings.local.php

The file should look something like this when you're done:


 * Database settings:
$databases['default']['default'] = array (
  'database' => 'drupal',
  'username' => 'databaseuser',
  'password' => 'databasepass',
  'prefix' => '',
  'host' => '',
  'port' => '4000',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',

Install the Site

Now, again, because I used the one-click install, Drupal is already installed into my database. I'm going to clear that out by simply dropping the database, and creating a new one of the same name.

drop database drupal;
create database drupal;

Now, I'll go to "/install.php" on the site.

If you're already familiar with Configuration Management in Drupal 8, you'll know that I can't just walk through the installation as normal, because when two distinct sites are installed separate of each other, they have different site UUIDs and therefor can not share configuration through Configuration Management.

In Drupal 7, that's exactly what you'd do. You'd install Drupal in various locations, and then use Features to push around configuration.

Drupal 8 is a little more restrictive with Configuration Management, since configuration should only be pushed to another instance of the same site, while Features are intended to be used across entirely different projects.

I'll go ahead and select English as my language, and continue.

Using the Configuration Installer profile

On the next step, you'll see the "standard" and "minimal" install profiles that you're used to, but you'll also see the "Configuration installer" profile that we installed earlier. I'll select that one, and continue.

On the next page, you'll see that it automatically picked up where my config is stored based on the info in settings.php. So, I can just click continue. (You could also upload a full site export if you haven't committed it to Git.)

Then, We're presented with a form to configure the site maintenance account. I'll go ahead and fill that in, and then continue.

After the install process has completed, we're ready with a fresh installation of Drupal 8 using the configuration we exported locally!