DebianDebian Based

How To Install Craft CMS on Debian 12

Install Craft CMS on Debian 12

In this tutorial, we will show you how to install Craft CMS on Debian 12. Craft CMS, a flexible and powerful content management system, has gained popularity among developers and content creators alike. Its intuitive interface, robust features, and high customizability make it a preferred choice for building and managing websites.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Craft CMS on a Debian 12 (Bookworm).


  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You will need an active internet connection to download the Craft CMS package.
  • A domain name pointed to your server IP (optional but recommended for a production environment).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Craft CMS on Debian 12 Bookworm

Step 1. Keeping your operating system up-to-date is a fundamental step in maintaining a secure and stable environment. To update your Debian 12 system, open your terminal and execute the following commands:

sudo apt update
sudo apt upgrade

 This will refresh your package lists and upgrade all your installed software to the latest versions.

Step 2. Create a Non-Root User

Operating as a non-root user with sudo privileges is a best practice for security. Create a new user and grant them the necessary permissions:

sudo /usr/sbin/adduser craftcms
sudo /usr/sbin/usermod -aG sudo craftcms
su - craftcms

Step 3. Installing LAMP Stack.

Before starting this tutorial, the LAMP server must be installed on your server. If you do not have LAMP Stack installed, you can follow our guide here.

Step 4. Create a Database for Craft CMS

Craft CMS requires a MySQL database to store its data. To create a new database, log in to MySQL as the root user:

sudo mysql -u root -p

Next, create a new database and user for Craft CMS:

CREATE USER 'craftuser'@'localhost' IDENTIFIED BY 'your-strong-password';
GRANT ALL PRIVILEGES ON craftcms.* TO 'craftuser'@'localhost';

Step 5. Installing Craft CMS Using Composer.

Craft CMS recommends using Composer, a dependency management tool for PHP, for installation. If you don’t have Composer installed, you can install it with the following commands:

curl -sS | php
sudo mv composer.phar /usr/local/bin/composer

Next, navigate to the Apache web root directory and install Craft CMS:

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

Step 6. Configure Apache for Craft CMS

To make Craft CMS accessible via the web, you need to configure Apache. Create a new configuration file for Craft CMS:

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

In the file, add the following configuration:

<VirtualHost *:80>
    DocumentRoot /var/www/html/craftcms/web
    <Directory /var/www/html/craftcms/web>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Replace ‘‘ with your domain name. Save and close the file, then enable the new site and rewrite the module:

sudo a2ensite craftcms
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 7. Securing Craft CMS with SSL.

First, you need to install Certbot, which is a client package that manages Let’s Encrypt SSL. You can install it using the following command:

sudo apt-get install python3-certbot-apache

Next, you can use Certbot to obtain and install an SSL certificate for your domain. Replace with your actual domain:

sudo certbot --apache -d

During the installation process, Certbot will prompt you for some basic information including your email address and domain name. Follow the prompts to complete the installation.

Step 8. Configure Firewall.

First, you need to install UFW, which is a user-friendly front-end for managing a Linux firewall. You can install it using the following command:

sudo apt update
sudo apt upgrade
sudo apt install ufw

Now we set up an Uncomplicated Firewall (UFW) with Apache to allow public access on default web ports for HTTP and HTTPS:

sudo ufw allow 'Apache Full'
sudo ufw allow 'Apache Secure'

Step 9. Access Craft CMS Web Interface

You can now access the Craft CMS installation wizard by navigating to your domain in a web browser. Follow the on-screen instructions to complete the installation.

Install Craft CMS on Debian 12 Bookworm

Congratulations! You have successfully installed Craft CMS. Thanks for using this tutorial to install the latest version of the Craft CMS on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Craft CMS website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button