Setup Drupal 10 On Ubuntu In 20 Minutes!

Points To Remember before you start

  • See our article HERE to setup your Drupal(linux) server
  • Check the composer requirements for the version of Drupal that you will install. 
  • For this article we will install Drupal 10 in the /srv/ directory
  • Install any package with sudo if you are not a root user
  • Don't run composer with sudo
  • This document was created December, 2022, but is updated by Simple Information staff regularly. 
  • If you get stuck, see the IN A JAM section at the bottom

Apache Web Server

How to install Apache web server

The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.

To install apache we need to run two commands given below:-

sudo apt-get update
sudo apt-get install apache2

At the end of the installation process, Ubuntu 18.04 starts Apache. The web server should already be up and running.

We can check with the systemd init system to make sure the service is running by typing:

sudo systemctl status apache2

Manage the Apache Process

Now that you have your web server up and running, we can go over some basic management commands.

To stop your web server, you can type:

sudo systemctl stop apache2

To start the web server when it is stopped, type:

sudo systemctl start apache2

To stop and then start the service again, type:

sudo systemctl restart apache2

If you are simply making configuration changes, Apache can often reload without dropping connections. To do this, you can use this command:

sudo systemctl reload apache2

By default, Apache is configured to start automatically when the server boots. If this is not what you want, you can disable this behavior by typing:

sudo systemctl disable apache2

To re-enable the service to start up at boot, you can type:

sudo systemctl enable apache2

Apache should now start automatically when the server boots again.

Enable modrewrite Module

sudo a2enmod rewrite



How to install PHP 7.2

In this article, we will show you how to install PHP 7.2 on Ubuntu 18.04. PHP (Hypertext Preprocessor) is an open-source server-side scripting language designed primarily for creating dynamic interactive websites. PHP is one of the most popular languages and it is freely available for redistribution and modifications. PHP can be run on almost any web server ( e.g. Nginx, Apache) and every OS platform (Linux, Mac OS, Windows). PHP 7.2 has been officially released last year and it is available for all RoseHosting clients. The latest PHP 7.2 release has new and improved features and functions that will allow developers to write better code. To install PHP7.2 in our system we need to run followings set of command in our server

sudo apt-get install software-properties-common
sudo apt-get update
sudo apt-get install -y php7.2

Now use the following command to check installed php version on your system.

php -v

You may also need to install modules based on your application requirements. Use the following command to search available PHP 7 modules in the package repository.

sudo apt-cache search php7.2*

You may want to install the most commonly used PHP modules for Drupal. Below is the command to do so. Make sure to install packages for correct PHP version by specifying the version with the package name. Without defining the package version, it will install the latest package.

sudo apt-get install mysql-client php7.2-dev php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-memcached php-pear php7.2-json php7.2-mbstring php7.2-intl php7.2-mysql php7.2-xml php7.2-zip php7.2-apcu php7.2-ctype php7.2-dom php7.2-iconv php7.2-imagick php7.2-opcache php7.2-pdo php7.2-mysqli php7.2-xml php7.2-tokenizer php7.2-simplexml php7.2-bcmath


Mariadb Database

How to install Mariadb 10.4

Here are the commands to run to install MariaDB 10.4 from the MariaDB repository on your Ubuntu system:

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] bionic main'

Once the key is imported and the repository added you can install MariaDB 10.4 from the MariaDB repository with:

sudo apt update
sudo apt install mariadb-server

Now at this stage your mariadb install successfully

How to set Root Password for mariadb

To do this, you need to stop the database from loading the grant tables, which store user privilege information. Because this is a bit of a security risk, you should also skip networking as well to prevent other clients from connecting. Start the database without loading the grant tables or enabling networking:

sudo mysqld_safe --skip-grant-tables --skip-networking &

This command will make this process run in the background so you can continue to use your terminal

Now you can connect to the database as the root user, which should not ask for a password.

mysql -u root

Now that you have root access, you can change the root password.


Now run this sql command to set root password

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

note:Make sure to replace new_password with your new password of choice.

Now kill the mysql process

sudo kill `/var/run/mariadb/`

Now restart mariadb

sudo systemctl start mariadb

Root password successfully updated now

Now you can confirm that the new password has been applied correctly by running:

mysql -u root -p



Installing PHP Composer

sudo apt-get update
sudo apt-get install curl

*Here's where life can get a little complicated. The latest version of composer doesn't always work with the latest version of Drupal 8/9. Make sure the composer version you install works with the Drupal 8 version that you will install. At the time of writing this article, Drupal 8.7 only supports composer version 1.7.0 although the latest version is 1.9.0 (

At the time of writing this article Drupal 8.7 supports composer version 1.7.0

curl -sS -o composer-setup.php && php composer-setup.php --version=1.7.0

Now we make composer globally available to all users

mv composer.phar /usr/local/bin/composer

To check your composer version

composer -V

Drupal Setup

Downloading Drupal core using composer

If you've been using the root user, now is the time to switch to a regular user that can run composer.  At this point you'll probably want to set your domain (ex. to point to your new server/Drupal site. Do do this, you'll need to create a Virtual host in apache. The details are beyond the scope of this article, so please refer to:

note: Make sure you point to your docroot directory (see below) in your virtual host

Run the following command from the directory for the Drupal root. If you want to use the Apache default, you can use /var/www/html/ as your site root. However, we generally use /srv/     (This command may take a few minutes to run; good time for a coffee?)

composer create-project drupal/recommended-project:10.0.0 docroot --no-interaction

This will download the current dev version of the 'drupal-composer/drupal-project' project into a folder named 'docroot' and then it automatically executes composer install which will download the latest stable version of Drupal 10 and all its dependencies.
* if you get an error similar to: Your requirements could not be resolved to an installable set of packages....see our IN A JAM section. 

Now run following bellow command from docroot

composer install

*if you get a memory swap error, see our IN A JAM section. 
Now create a config directory in docroot

mkdir config
cd config
mkdir sync

To check if drupal installed or not, check for the core directory in web folder (ex. /var/www/html/docroot/web or /srv/docroot/web)

Note: There is  no need to install drush explicitly , Its comes with the drupal 10 installation in the “vendor/bin/drush” directory.

You may want to download contributed modules and themes using Composer

Run below command from docroot

composer require 'drupal/*modulename*:*version*'
composer require 'drupal/token:^1.5'
composer require 'drupal/simple_fb_connect:~3.0'
composer require 'drupal/ctools:3.0.0-alpha26'
composer require 'drupal/token:1.x-dev'


To know about composer version notation see below link

To know about drupal installation in details see below link

Run Drupal

Now you should be able to see the fruits of your hard work by running your instance.

Here, substitute your IP address for If you have already configured apache to use your own domain, you can use that instead of the IP address. 


Composer Issues:

Issue : webflo/drupal-core-require-dev 10.x-dev requires behat/mink-selenium2-drive requires behat/mink-selenium2-driver 1.3.x

  • Just go to /srv/docroot and remove the following lines from composer.json below
  • "require-dev": { "webflo/drupal-core-require-dev": "^10.0" },
  • DO NOT RUN composer create-project again

Refer :

Issue : If youre getting [ErrorException] proc_open(): fork failed - Cannot allocate memory. Run the below command one after another can fix your issue

Run this command one after another

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

Did we miss something or not get something right? Contact Us