How to install Craft CMS on Fedora 29

How to install Craft CMS on Fedora 29

Craft is an open source CMS written in PHP. Craft makes it easy to create and manage beautiful content and precisely design and build what you need. It is a secure and scalable CMS with a large plugin ecosystem, and Craft source code is hosted on GitHub. This tutorial will guide you through the process of installing Craft CMS on a new Fedora 29 system using Nginx as a web server, and we will use a “Let’s Encrypt SSL” certificate to secure the website.


Craft requires the following:

  • PHP 7.0 or higher with the following PHP extensions: (ctype, cURL, GD or ImageMagick, iconv, JSON, multibyte string, OpenSSL, PCRE, PDO MySQL driver or PDO PostgreSQL driver, PDO, Reflection, SPL, Zip, Intl, DOM)
  • MySQL 5.5+ with InnoDB, MariaDB 5.5+ or PostgreSQL 9.5+
  • At least 256MB of memory allocated to PHP
  • At least 200MB of free disk space


  • An operating system running Fedora 29.
  • A non-root user with sudo privileges.

Preliminary steps

Check your Fedora system version:

cat /etc/fedora-release# Fedora release 29 (Twenty Nine)

Set time zone:

timedatectl list-timezonessudo timedatectl set-timezone 'Region/City'

Update your operating system package (software). This is an important first step because it ensures that you have the latest updates and security fixes for the operating system’s default packages:

sudo dnf upgrade -y

Install some basic packages that are required for basic management of the Fedora operating system:

sudo dnf install -y curl wget vim git sudo unzip socat bash-completion

Step 1-install PHP and required PHP extensions

Install PHP and necessary PHP extensions:

sudo dnf install -y php-cli php-fpm php-common php-curl php-gd php-pecl-imagick php-json php-mbstring php-mysqlnd php-pgsql php-zip php-intl php-xml php-pdo

To display PHP compiled in the module, run:

php -mctypecurlexiffileinfo. . .. . .

Check PHP version:

php --version# PHP 7.2.16 (cli) (built: Mar  5 2019 11:05:59) ( NTS )# Copyright (c) 1997-2018 The PHP Group# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Run sudo vim /etc/php.ini And set memory_limit at least 256MB:

memory_limit = 256M

Start and enable the PHP-FPM service:

sudo systemctl start php-fpm.servicesudo systemctl enable php-fpm.service

We can move on to the next step, which is database installation and setup.

Step 2-install MariaDB and create database

Craft CMS supports MySQL / MariaDB and PostgreSQL databases. In this tutorial, we will use MariaDB as the database server.

Install MariaDB database server:

sudo dnf install -y mariadb-server

Check MariaDB version:

mysql --version# mysql  Ver 15.1 Distrib 10.3.12-MariaDB, for Linux (x86_64) using readline 5.1

Start and enable MariaDB service:

sudo systemctl start mariadb.servicesudo systemctl enable mariadb.service

Run mysql_secure installation Script to increase MariaDB security and set password for MariaDB root user:

sudo mysql_secure_installation

Answer each question:

New password: your_secure_passwordRe-enter new password: your_secure_passwordRemove anonymous users? [Y/n] YDisallow root login remotely? [Y/n] YRemove test database and access to it? [Y/n] YReload privilege tables now? [Y/n] Y

Connect to MariaDB Shell as root user:

sudo mysql -u root -p# Enter password

Create an empty MariaDB database and user for Craft CMS and remember the credentials:

mariadb> CREATE DATABASE dbname;mariadb> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';mariadb> FLUSH PRIVILEGES;

Exit from MariaDB:

mariadb> exit

Replace dbname, username with password Use your own name.

Step 3-Installation Client and get “Let’s Encrypt” certificate (optional)

You don’t have to use HTTPS to protect your website, but it is a good habit to protect your website traffic. In order to obtain a TLS certificate from Let’s Encrypt, we will use the client. is a pure UNIX Shell software for obtaining TLS certificates from Let’s Encrypt with zero dependencies.

Download and install

sudo mkdir /etc/letsencryptgit clone sudo ./ --install --home /etc/letsencrypt --accountemail [email protected]cd ~

Check the version:

/etc/letsencrypt/ --version# v2.8.0

Gain RSA with ECC / ECDSA Your domain / hostname certificate:

# RSA 2048sudo /etc/letsencrypt/ --issue --standalone --home /etc/letsencrypt -d --keylength 2048# ECDSAsudo /etc/letsencrypt/ --issue --standalone --home /etc/letsencrypt -d --keylength ec-256

After running the above command, your certificate and key will be located at:

  • For RSA: /etc/letsencrypt/ table of Contents.
  • For ECC / ECDSA: /etc/letsencrypt/example.com_ecc table of Contents.

Step 4-install and configure NGINX

Craft CMS works with many popular web server software. In this tutorial, we chose Nginx.

Install NGINX Web Server:

sudo dnf install -y nginx

Check NGINX version:

nginx -v# nginx version: nginx/1.14.2

Start and enable the NGINX service:

sudo systemctl start nginx.servicesudo systemctl enable nginx.service

Configure NGINX for Craft CMS by running:

sudo vim /etc/nginx/conf.d/craft.conf

And populate the file with the following configuration:

server {  listen 80;  listen [::]:80;  listen 443 ssl;  listen [::]:443 ssl;  server_name;  root /var/www/craft/web;  index index.php;  ssl_certificate /etc/letsencrypt/;  ssl_certificate_key /etc/letsencrypt/;  ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.cer;  ssl_certificate_key /etc/letsencrypt/example.com_ecc/;  location / {    try_files $uri/index.html $uri $uri/ /index.php?$query_string;  }  location ~ [^/].php(/|$) {    include default.d/php.conf;    try_files $uri $uri/ /index.php?$query_string;    fastcgi_split_path_info ^(.+.php)(/.+)$;    fastcgi_pass unix:/run/php-fpm/www.sock;    fastcgi_index index.php;    include fastcgi_params;    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;    fastcgi_param PATH_INFO $fastcgi_path_info;    fastcgi_param HTTP_PROXY "";  }}

In the above file, replace with your own domain name.

note: For a complete and production-ready Nginx configuration for Craft, visit The configuration was intentionally simplified to keep it dense and simple.

Test the NGINX configuration:

sudo nginx -t

Reload NGINX:

sudo systemctl reload nginx.service

Step 5-install Composer

Install Composer (PHP dependency manager) globally:

php -r "copy('', 'composer-setup.php');"php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"php composer-setup.phpphp -r "unlink('composer-setup.php');"sudo mv composer.phar /usr/local/bin/composer

Check Composer version:

composer --version# Composer version 1.8.4 2019-02-11 10:52:10

note: Composer’s installation commands will change in the future, so if the above command does not work, check for the latest command.

Step 6-Install Craft CMS

Craft CMS can be downloaded via Composer or manually .zip Either tar.gz Archive. In this tutorial, we will use Composer to download Craft CMS.

Create a document root directory where Craft CMS should reside:

sudo mkdir -p /var/www/craft

Navigate to the document root:

cd /var/www/craft

Change ownership /var/www/craft Directory to {your username}.

sudo chown -R {your_username}:{your_username} /var/www/craft

To create a new Craft project, run the following command:

composer create-project craftcms/craft .

Change ownership /var/www/craft Directory to nginx:

sudo chown -R nginx:nginx /var/www/craft

Run sudo vim /etc/php-fpm.d/www.conf And set users and groups to nginx. Initially, they will be set to apache:

sudo vim /etc/php-fpm.d/www.conf# user = nginx# group = nginx

Create /var/lib/php/session/ Directory and change ownership to nginx.

sudo mkdir -p /var/lib/php/session && sudo chown -R nginx:nginx /var/lib/php/session

Restart the PHP-FPM service:

sudo systemctl restart php-fpm.service

In your web browser, go to http:///index.php?p=admin/install (Substitute And the hostname of your web server). If you have everything so far, Craft’s setup wizard will say hello.

Step 7- complete Craft CMS setup

After opening the installation URL, the following page should be displayed. Please click “Installing Crafts” Button:

By clicking “got it” Button:

Accept license

Fill in the database details and click “next” Button:

Connect to the database

Create a Craft Account and click “next” Button:

Create a user

Set up your website and click “Done” Button:

Add website information

After that, you should be redirected to the Craft admin page:

Craft CMS Dashboard