Get started with Drupal 8 - The beginners guide

It is always exciting to start a new project or try a new CMS system for the first time.

Drupal 8 can help you quickly build a fast, scalable website whether you are a small blogger or a large, international corporation.

In this article, we will show you how to download and configure your new Drupal 8 website using different tools.
 

Table of Contents

Toggle

Install & Configure Composer for Drupal 8

This is an optional but highly recommended step. You can use Composer to download and install Drupal 8 and Drush.

What is Composer?

Composer is a command line tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Learn more about Composer

Install Composer

If you already have Composer installed, you can skip this step.

Let's install Composer globally:

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

Edit your .bash_profile file in your home directory and add Composer

$ export PATH="$HOME/.composer/vendor/bin:$PATH"

Save the file and reload the .bash_profile file to activate the changes

$ source ~/.bash_profile

Now that we have access to Composer, we can continue by installing Drupal 8 via Drush or directly via Composer.

Create a database for Drupal 8

We will assume that you already installed and configured MySQL (or MariaDB) on your server.

If you haven't yet, know that Drupal 8 supports the following database engines:

  • MySQL 5.5.3 or higher
  • MariaDB 5.5.20 or higher
  • Percona Server 5.5.8 or higher

with InnoDB as the primary storage engine, and requires the PDO database extension.

The following example will show you how to create a new user and database in MySQL or MariaDB

Login to MySQL as root

$ mysql -u root -p

Create a new MySQL user called "drupal" and a new database called "drupal8" for your Drupal 8 website.

> CREATE DATABASE drupal8;
> CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON drupal8.* TO 'drupal'@'localhost';
> FLUSH PRIVILEGES;
> quit

How to Install Drupal 8 with Drush?

What is Drush?

Drush is a command line tool to maintain and administer Drupal websites.

Learn more about Drush

Install Drush via Composer

Use the following commands to install Drush 8 and update all dependencies.

$ composer global require drush/drush:dev-master
$ composer global update

You can check the current version of Drush

$ drush --version

Download Drupal 8 using Drush

Now that we have Composer and Drush installed, let's use the following command to download Drupal 8.
You will be able to select which version of Drupal 8 you would like to download using this command:

$ drush dl drupal-8 --select

dl is shorthand for download. drupal-8 is the Drupal version you are after. You can also use drupal-7 if you would like to download the previous version of Drupal.

It is recommended to use the "Supported, Recommended" version of Drupal 8 unless you would like to get the latest development version.

Once you have selected the preferred version, Drush will download all the necessary files and create the Drupal folder structure for you. This was not too bad so far. Let's see how to get your brand new Drupal 8 website up and running.

Install Drupal 8 Standard Profile via Drush

Using the new credentials, install the standard Drupal 8 profile. Don't forget to replace the username, password and database name.

$ drush si standard --db-url=mysql://[db_user]:[db_pass]@[ip-address]/[db_name]

Once the installation is complete, your new Drupal 8 website is ready to be used. However, to ensure everything works correctly, don't forget to update permissions on some of the folders and files. See instructions further down.

Why use Drush with Drupal 8?

Drush is a simple command line tool helping you to do your every-day maintenance tasks quicker and more efficiently.

If you need more information about how to use Drush, check their official website.

How to Install Drupal 8 with Composer?

The following command will download the drupal-composer/drupal-project project into a folder called my-drupal8-site and download and install all Drupal 8 dependencies.

$ composer create-project drupal-composer/drupal-project:8.x-dev my-drupal8-site --stability dev --no-interaction

This is what you get, what it means, how it works. The composer file means this and contains this.

Why use Composer with Drupal 8?

Composer is a great tool to manage dependencies of your Drupal 8 installation. You will find that most of the Drupal 8 modules and themes have additional external libraries they depend on. Using Composer, you will be able to manage/update all these dependencies in one place.

How to install Drupal 8 with Drupal Console?

What is Drupal Console?

The Drupal Console or CLI is a command line tool to generate boilerplate code, interact with and debug Drupal.

Learn more about Drupal Console

Download and install Drupal 8 with Drupal Console

Luckily, Drupal Console comes with a cool interactive option. You can install Drupal 8 quickly using this option.

The steps are similar to the Drush installation and the result is the same. Which tool to use is purely down to preference.

$ drupal site:new

This will prompt you to select your preferred Drupal 8 version. Normally, you want to pick the stable version which is sitting on the top of the list.

Once the download is complete, we will install Drupal 8 using the interactive mode.

$ drupal site:install

You will be prompted to select your installation profile, which probably should be "Standard".

Pick "English" as language and select your database type, eg. MySQL, MariaDB, etc.

Enter your database host, username and password when prompted. We have created these earlier in this article.

Leave any values empty for defaults. eg. Database port 3306.

Select a "Site name" and enter your email address at the last step. This email address will be used to notify you of issues with your Drupal 8 site.

That's it. Your new website is ready. Please check the last step for file permissions before you go.

After installing Drupal 8

For security, you will have to update the permissions on the sites/default/settings.php file.
For simplicity, you can update the sites/default/files folder permissions to 777 or you can change owner to the webserver user and give it full access.

Drupal 8 will need full read, write and delete permissions on the files folder and all its subfolders in order to work as expected.

$ chmod 755 sites/default/settings.php
$ chmod -R 777 sites/default/files

All done! Congratulations! Your new Drupal 8 website should be accessible via the browser.

Stuck? Get in touch for Professional help!