How to Install Anchor CMS on Debian 9

Anchor is a super-simple, lightweight blog system written in PHP. Anchor's source code is hosted on GitHub. In this tutorial, we will go through the Anchor CMS installation process on a Debian 9 (stretch) operating system by using NGINX as a web server and MariaDB as a database server.


Make sure your server meets the following requirements.

  • MySQL 5.6 or greater (MySQL 5.7 recommended)
  • PHP 7.1 or greater with the following PHP extensions: (curl, mcrypt, gd, mbstring, pdo_mysql or pdo_sqlite)
  • Apache or NGINX web server software installed. In this tutorial, we will use NGINX.


  • Debian 9 operating system.
  • A non-root user with sudo privileges.

Initial steps

Check your Debian system version:

lsb_release -ds
# Debian GNU/Linux 9.7 (stretch)

Set up the timezone:

dpkg-reconfigure tzdata

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

apt update && apt upgrade -y

Install some essential packages that are necessary for basic administration of the Debian operating system:

apt install -y curl wget vim git sudo unzip socat bash-completion dirmngr apt-transport-https

Step 1 - Install PHP and necessary PHP extensions

Anchor CMS requires PHP version 7.1 or greater. Debian has PHP version 7 in the default repository, thus you will need to use third-party repo to install newer version.

sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

Install PHP, as well as the necessary PHP extensions:

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-curl php7.2-mysql php7.2-sqlite3 php7.2-gd php7.2-xml

Check the PHP version:

php --version

# PHP 7.2.16-1+0~20190307202415.17+stretch~1.gbpa7be82 (cli) (built: Mar  7 2019 20:24:15) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
# with Zend OPcache v7.2.16-1+0~20190307202415.17+stretch~1.gbpa7be82, Copyright (c) 1999-2018, by Zend Technologies

Step 2 - Install MariaDB and create a database for Anchor CMS

Anchor supports MySQL/MariaDB and SQLite databases. Default Debian repository contains an unsupported version of MariaDB. Because of that, we will use the official MariaDB repository that contains a newer version of MariaDB.

Install MariaDB:

sudo apt install -y mariadb-server

Check the MariaDB version:

mysql --version
# mysql  Ver 15.1 Distrib 10.1.37-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Run mysql_secure installation script to improve MariaDB security and set the password for MariaDB root user:

sudo mysql_secure_installation

Answer all the questions as shown below:

Enter current password for root (enter for none):
Set root password? [Y/n]: Y
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

Log into MariaDB shell as the user root:

mysql -u root -p
# Enter password

Create a MariaDB database and user that you will use for your installation of Anchor CMS, and remember the credentials:

GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';

Exit from MariaDB shell:


Step 3 - Install and configure NGINX

Install the NGINX web server:

sudo apt install -y nginx

Check the NGINX version:

nginx -v
# nginx version: nginx/1.10.3

Run sudo vim /etc/nginx/sites-available/anchor.conf and populate the file with the following configuration:

server {
    listen 80;

    root /var/www/anchor;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php;
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
include fastcgi_params; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }

Activate the new anchor.conf configuration by linking the file to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/anchor.conf /etc/nginx/sites-enabled

Check NGINX configuration for syntax errors:

sudo nginx -t

Reload NGINX service:

sudo systemctl reload nginx.service

Step 4 - Download and install Composer

To successfully install Anchor, we will need to install Composer, the dependency manager for PHP applications:

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.php

php -r "unlink('composer-setup.php');"

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

Check the Composer version.

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

Step 5 - Download and install Anchor CMS

Create a document root directory:

sudo mkdir -p /var/www/anchor

Change ownership of the /var/www/limesurvey directory to [jour_user]:

sudo chown -R [your_user]:[your_user] /var/www/anchor

Navigate to document root:

cd /var/www/anchor

Download the latest release of Anchor CMS by using Composer:

composer create-project anchorcms/anchor-cms .

Change ownership of the /var/www/anchor directory to www-data:

sudo chown -R www-data:www-data /var/www/anchor

Create the directory/var/lib/php/session and set ownership to nginx:

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

Step 6 - Complete the Anchor CMS setup

Open your web browser and type the URL "". You will be redirected to the following page:

Anchor CMS web installer

Click on the "Run the installer" button, to initiate Anchor CMS web installer. After, language and timezone page should appear:

Select Language and Time zone

Select the settings that you want and click on the "Next Step" button to proceed to the database configuration page:

Database settings

Enter your database details, and click on the "Next Step" button to proceed to site metadata configuration page:

Site Metadata

You can set site name or site description here, or leave the defaults and change it later via Anchor backend interface. Click on the "Next Step" button for the next step which is setting your first account:

Create admin account

After setting up your first account, click on the "Complete" button to finish the installation process.

Once you have completed the install, make sure to delete install folder for security purposes.

sudo rm -rf /var/www/anchor/install


Share this page:

Suggested articles

0 Comment(s)

Add comment