Pagekit is a modern, intuitive, modular, and flexible open-source (MIT license) CMS built with Symfony components and Vue.js. It gives you the tools to create beautiful websites. It has a rich theme and plugin system.

In this tutorial, we will walk you through the Pagekit CMS installation process on a FreeBSD 12 operating system by using Nginx as a web server, MariaDB as a database server, and optionally you can secure the transport layer by using acme.sh client and Let’s Encrypt certificate authority to add SSL support.

Requirements

To install Pagekit, make sure your server meets the following requirements:

  • Apache version 2.2 or greater or NGINX web server.
  • MySQL version 5.1 or greater or SQLite 3.
  • PHP version 5.5.9 or greater.
  • Required PHP extensions: JSON, Session, ctype, Tokenizer, SimpleXML, DOM, mbstring, PCRE 8.0 , ZIP and PDO with MySQL or SQLite drivers.
  • Optional PHP extensions: cURL, iconv and XML Parser, as well as APC or XCache for caching.
  • An operating system running FreeBSD 12.
  • A non-root user with sudo privileges.

Initial steps

Check your FreeBSD version:

uname -ro
# FreeBSD 12.0-RELEASE

Set up the timezone:

tzsetup

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:

freebsd-update fetch install
pkg update && pkg upgrade -y

Install some essential packages that are necessary for basic administration of FreeBSD 12.0 operating system:

pkg install -y sudo vim unzip wget bash

Step 1 – Install PHP and necessary PHP extensions

Pagekit CMS platform requires PHP version 7.0 or greater. FreeBSD 12 contains PHP 7.2 and 7.3 versions in its default repository, so the installation is easy.

Download and install PHP and required PHP extensions:

sudo pkg install -y php72 php72-mbstring php72-tokenizer php72-pdo php72-pdo_mysql php72-openssl php72-hash php72-json php72-phar php72-filter php72-zlib php72-dom php72-xml php72-xmlwriter php72-xmlreader php72-curl php72-session php72-ctype php72-iconv php72-gd php72-simplexml php72-zip php72-filter php72-tokenizer php72-calendar php72-fileinfo php72-intl php72-phar php72-soap php72-xmlrpc php72-opcache php72-mysqli php72-bcmath php72-gmp php72-exif php72-imap php72-pecl-APCu

To show PHP compiled in modules, you can run:

php -m

ctype


curl


exif


fileinfo


. . .


. . .

Check the PHP version:

php --version
# PHP 7.2.14 (cli) (built: Jan  8 2019 09:59:17) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies

Start and enable PHP-FPM service:

sudo sysrc php_fpm_enable=yes
sudo service php-fpm start

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

Step 2 – Install MariaDB and create a database for Pagekit

Pagekit CMS supports MySQL, MariaDB and SQLite databases. In this tutorial, we will use MariaDB as the database server.

Install MariaDB database server:

sudo pkg install -y mariadb102-client mariadb102-server

Check the MariaDB version:

mysql --version
# mysql Ver 15.1 Distrib 10.2.25-MariaDB, for FreeBSD12.0 (amd64) using readline 5.1

Start and enable MariaDB service:

sudo sysrc mysql_enable="yes"
sudo service mysql-server start

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

sudo mysql_secure_installation

Answer each of the questions:

Enter current password for root (enter for none): Press Enter
Set root password? [Y/n] Y
New password: your_secure_password
Re-enter new password: your_secure_password
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 as the root user:

sudo mysql -u root -p
# Enter password

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

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

Exit from MariaDB shell:

quit

Step 3 – Install Acme.sh client and obtain Let’s Encrypt certificate (optional)

Securing your website with HTTPS is not necessary, but it is a good practice to secure your site traffic. In order to obtain an SSL certificate from Let’s Encrypt we will use Acme.sh client. Acme.sh is a pure UNIX shell software for obtaining SSL certificates from Let’s Encrypt with zero dependencies.

Download and install acme.sh:

sudo pkg install acme.sh

Check acme.sh version:

acme.sh --version
# v2.8.2

Obtain RSA and ECC/ECDSA certificates for your domain/hostname:

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

If you want fake certificates for testing you can add --staging flag to the above commands.

To list your issued certs you can run:

acme.sh --list

Create a directory to store your certs. We will use /etc/letsencrypt directory.

sudo mkdir -p /etc/letsencrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

Install/copy certificates to /etc/letsencrypt directory.

# RSA
acme.sh --install-cert -d example.com  
        --cert-file /etc/letsencrypt/example.com/cert.pem 
        --key-file /etc/letsencrypt/example.com/private.key 
        --fullchain-file /etc/letsencrypt/example.com/fullchain.pem 
        --reloadcmd "sudo systemctl reload nginx.service"

# ECC/ECDSA


acme.sh –install-cert -d example.com –ecc


–cert-file /etc/letsencrypt/example.com_ecc/cert.pem


–key-file /etc/letsencrypt/example.com_ecc/private.key


–fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem


–reloadcmd “sudo systemctl reload nginx.service”

After running the above commands, your certificates and keys will be in:

  • For RSA: /etc/letsencrypt/example.com directory.
  • For ECC/ECDSA: /etc/letsencrypt/example.com_ecc directory.

All the certificates will be automatically renewed every 60 days.

After obtaining certs, exit from root user and return back to normal sudo user:

exit

Step 4 – Install NGINX and configure NGINX for Pagekit

Install Nginx webserver software:

sudo pkg install -y nginx

Check the NGINX version:

nginx -v
# nginx version: nginx/1.16.2

Start and enable Nginx service:

sudo sysrc nginx_enable=yes
sudo service nginx start

Configure NGINX for Pagekit by running:

sudo vim /usr/local/etc/nginx/pagekit.conf

And populate the file with the following configuration:

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;
    listen [::]:80;
    listen 80;
    
    server_name example.com;
    
    index index.php index.html;
    root /usr/local/www/pagekit;
    ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/example.com/private.key;
    ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
location ~ .php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
} }

Run sudo vim /usr/local/etc/nginx/nginx.conf and add the below line to http {} block to include Pagekit config.

include pagekit.conf;

Check NGINX configuration for syntax errors:

sudo nginx -t

Reload NGINX service:

sudo service nginx reload

Step 5 – Download and install Pagekit CMS

Create a document root directory where Pagekit should reside in:

sudo mkdir -p /usr/local/www/pagekit

Navigate to document root:

cd /usr/local/www/pagekit

Download the latest stable release of Pagekit CMS via wget:

sudo wget https://github.com/pagekit/pagekit/releases/download/1.0.17/pagekit-1.0.17.zip

Unpack Pagekit CMS content and remove downloaded .zip file.

sudo unzip pagekit-1.0.17.zip
sudo rm pagekit-1.0.17.zip

Provide the appropriate ownership:

sudo chown -R www:www /usr/local/www/pagekit

Restart PHP-FPM service:

sudo service php-fpm restart

Step 6 – Complete the Pagekit setup

Open your site in a web browser and you should see the following page:

How to Install Pagekit CMS with Nginx on FreeBSD 12 FreeBSD

Click on the right arrow icon to proceed with the installation. Choose your language and click “Next” button:

How to Install Pagekit CMS with Nginx on FreeBSD 12 FreeBSD

Next, choose your database either SQLite or MySQL and populate required fields and click the “Next” button:

How to Install Pagekit CMS with Nginx on FreeBSD 12 FreeBSD

After that, set up your site by entering Site Title and creating an admin user account:

How to Install Pagekit CMS with Nginx on FreeBSD 12 FreeBSD

And that should be it. You will be redirected to the Pagekit login page. Provide your username and password to log into the Pagekit dashboard.

How to Install Pagekit CMS with Nginx on FreeBSD 12 FreeBSD

That’s all. If you stuck, check out the official Pagekit docs.

Links