How to install Craft CMS on Ubuntu 20.04 LTS Focal Fossa

Just like WordPress, we have another open-source Craft CMS that is a new and innovative content management system with a large community of developers and communities worldwide. Here we learn the steps to Install Craft CMS on Ubuntu 20.04 or 18.04.

It is an open-source CMS based on PHP / MySQL with the TWIG template engine, flexible in nature, and has a user-friendly interface for creating digital current and administrative tasks. Craft CMS also offers a built-in plugin store with hundreds of free and paid plugins. Whereas is robust framework allows developers to develop modules and plugins.

Steps to Install Craft CMS with Apache on Ubuntu 20.04/18.04 LTS

Here in this tutorial, we have given the step-by-step guide to Install Craft CMS on Ubuntu 20.04 LTS server OS running locally or some cloud hosting server.

System Requirement for Craft CMS

Minimum System requirement:

  • For DB: MySQL 5.5+ with InnoDB, MariaDB 5.5+, or PostgreSQL 9.5+
  • PHP 7.2.5+
  • 256MB+ memory allocated to PHP
  • 200MB+ free disk space

Recommended System requirement:

  • PHP 7.4*
  • MySQL 5.7+ with InnoDB, MariaDB 10.5+, or PostgreSQL 10+
  • 512MB+ of memory allocated to PHP
  • 200MB+ of free disk space
  • Composer 1.3+ if installing Craft via Composer

Run system update

To install any packages, first, we should update our system to its latest state. For that, run the Ubuntu update command that will also refresh the repository cache.

sudo apt update

Also install curl, nano, and git:

sudo apt install curl nano git


Install Apache Web server on Ubuntu 20.04

Here we are using Apache to serve as a web server for Craft CMS, well, it is one of the popular open-source projects running on millions of servers and we just need to run a single command for its installation.

sudo apt install apache2

Start and enable the Apache service

Once the installation of this web server is completed, make sure to start and enable its service using the below-given commands:

sudo systemctl start apache2
sudo systemctl enable apache2

To check the service status:

systemctl status apache2


Install PHP and extensions required by Craft CMS

By default on Ubuntu 20.04 LTS, while writing this article the version of PHP was 7.4, however, don’t worry, the below-given command will install whatever the latest version is available for your system via base repo.

apt install php-{common,mysql,gmp,curl,intl,mbstring,imagick,fpm,mysql,pgsql,json,xmlrpc,gd,bcmath,xml,cli,zip}

Once the installation is completed check the PHP version.

php -v

Now use that version in the below command to edit the php.ini file.

For example, we have version 7.4.24, hence the edit command will be like this:

nano /etc/php/7.4/fpm/php.ini

Now, find below lines in the file and change the values as given:

memory_limit = 512M
post_max_size = 32M
upload_max_filesize = 32M
max_execution_time = 360

Save and close the file by pressing Ctrl+O, hit the Enter key, and to exit use Ctrl+X.

Restart Apache:

sudo systemctl restart apache2


Install MariaDB Database server on Ubuntu 20.04/18.04

To store the content of Craft CMS we can either use MySQL or PostgreSQL. Hence here we are using the open-source fork of MySQL i.e MariaDB.

sudo apt install mariadb-server mariadb-client

Start and enable the database services:

sudo systemctl start mysql
sudo systemctl enable mysql

To check status:

systemctl status mysql

Once the installation is completed. Secure the installation using this command:

sudo mysql_secure_installation

It will ask few steps to secure your MySQL/MariaDB installation by setting root user passwords for the Database server, removing demo users and databases. Hence, just follow the text wizard.

Create Database for Craft CMS

Now, let’s create a Database for this content management system. First, log in to the database server;

sudo mysql -u root -p

Create DB:


Create a database user:

CREATE USER 'h2suser'@'localhost' IDENTIFIED BY 'mypassword';

Grant all rights of created database to the user:

GRANT ALL ON craftcmsdb.* TO 'h2ssuser'@'localhost';



Note: Change the values given in red color as per your choice.


Download CraftCMS on Ubuntu 20.04 or 18.04 to install

We need Composer on our Ubuntu 20.04 LTS server to install Craft CMS, hence use the below to download and run its installation script.

curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

After installing, use the composer to download the Craft CMS. Let’s switch to the Apache www root directory and download the project files.

cd /var/www/html
composer create-project craftcms/craft craftcms

Give the  downloaded CraftCMS files read and execute permission to the system’s apache user:

sudo chown -R www-data:www-data /var/www/html/craftcms/
sudo chmod -R 755 /var/www/html/craftcms/

download craft CMS files on Ubuntu 20.04

The setup will also ask you to enter the MySQL database details. Hence, leave the database port as it is while giving the database name, username, and password when it asks for.


Create Apahce2 site configuration file for CraftCMS

To access CraftCMS, create a site configuration file with values to access this content management system using the webserver.

sudo nano /etc/apache2/sites-available/craftcms.conf

Paste the following block of code:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/craftcms/web

     <Directory /var/www/html/craftcms/web/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
     <Directory /var/www/html/craftcms/web/>
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*) index.php [PT,L]


Enable Craft CMS Apache configuration

Next, enable the above created CMS configuration file, rewrite module, and disable the default Apache configuration.

sudo a2ensite craftcms.conf
sudo a2dissite 000-default
sudo a2enmod rewrite
sudo systemctl restart apache2


Access Web Interface

Now, go to your browser. Either enter the website URL (domain) you set to use with the CMS or simply enter the IP address of the server where the Craft CMS has been installed.


Login with the credentials you have set.

Login Craft CMS on Ubuntu Front End Screenshot Craft CMS install on Ubuntu 20.04 LTS


Other Articles:

Install Etherpad Lite on Ubuntu 20.04…
How to install WHM & CPanel on Ubuntu 20.04 LTS
Install ImageMagick or its PHP module on Ubuntu
How to install Gfortran 9, 10, or 11 on Ubuntu 20.04…



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.