Archive of

Installing Chyrp-Lite, a lightweight micro blogging platform in OpenBSD 7.2

Written by Saïd

With an old-school internet spirit and its self-hosted, self-managed dinky websites, there is always a temptation to venture off the beaten tracks and popular products for blogging. Whether it is managed or self-hosted (WordPress, Blogger, Medium, Substack, etc.), popular stacks or CMS, or popular operating systems for bare-metal hosting (Debian, Ubuntu, Enterprise Linux-like, etc.), I've chosen to use a very niche blogging platform on a very niche operating system: Chyrp-Lite on OpenBSD.

It is always tricky when you use such niche products because it might require you to invest time into learning how to get it to work and to maintain it. It is understandable to wonder why spend so much time when you can use a managed solution or a popular stack that is easy to install and maintain. It depends on your goal: whether it is to spend more time learning how to install a website from scratch and how to maintain it, or spend more time being productive as a writer and delivering content. I am a terrible writer, so my goal was to create my own website using an uncommon blogging platform on a niche OS just as a hobby.

OpenBSD might not be the most efficient operating system, due to its "market share" and user base, and subsequently the support they can get from hardware/chips/software makers. However, it is widely recognized for its security, which is their main argument as they like to advertise: "Only two remote holes in the default install, in a heck of a long time!". Its solid TCP stack, low weight, and licensing make it more suitable for some edge cases.

Same goes for the hosting solution, I went with a small hosting company : OpenBSD.amsterdam. Other providers do offer OpenBSD as an option, others don’t but enable the use of custom images.

Required stack :

  • Web-server software
  • PHP with default extensions (Session, JSON, Ctype, libxml, SimpleXML)
  • PDO to enable PHP to access our database
  • MySQL 4.1+ or SQLite 3+ or PostgreSQL 10+

The VM :

The version we will be using is OpenBSD 7.2-release. The process to book the VM at OpenBSD.amsterdam is the most human-friendly I've ever experienced. After filling the necessary information on the website (SSH public key, RAM and HDD size, ...) I quickly got a friendly email from Mischa that shared my VM details on the spot, knowing that I did not pay yet and I was able to connect and test it. Upon connecting I recovered and changed the root password as explained here. I then disabled root SSH logging and password login for the user account and enforced the use of SSH public key authentication in the sshd configuration file /etc/ssh/sshd_config :

PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no

After updating/upgrading the host, install the web server :

openbsdhost# syspatch
openbsdhost# pkg_add -u

The web server :

OpenBSD comes with a web-server out of the box, httpd. I struggled with configuration files and I was not sure I would be able to get it to work with PHP. I went with the industry standard Nginx :

openbsdhost# pkg_add nginx
openbsdhost# rcctl enable nginx
openbsdhost# rcctl start nginx

Edit the nginx configuration files /etc/nginx/nginx.conf to add index.php to the index option in http section :

index         index.html index.htm index.php;

Also to nginx.conf, add the following to the “server” section so the PHP pages can be interpreted :

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass   unix:run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

And last, test the nginx conf :

openbsdhost# nginx -t

If you got an output that the syntax is ok, you can move to the next section.

Installing PHP

install php 8.0.26 and its required modules as follows :

openbsdhost# pkg_add php php-gd php-intl php-xmlrpc

Enable and start PHP-FPM, the FastCGI Process Manager :

openbsd-host# rcctl enable php80_fpm
openbsd-host# rcctl start php80_fpm

Install the modules that will enable PHP to connect to MySQL:

openbsdhost# pkg_add php-mysqli php-pdo_mysql

Copy the configuration sample to the main PHP folder :

openbsdhost# cp /etc/php-8.0.sample/* /etc/php-8.0

Create a php test file in /var/www/hdtocs/test.php containing the code below and try accessing it using your http://server-public-ip/test.php, this might require rebooting your server/services to work :

<?php
phpinfo();
?>

If you are getting the phpinfo output on your web browser, then PHP is working as expected. You may delete the test.php file and move on.

Installing and configuring MySQL :

Install, initialize, enable, and start MariaDB server. I used MariaDB 10.9.3(MySQL 15.1) :

openbsdhost# pkg_add mariadb-server
openbsdhost# mysql_install_db
openbsdhost# rcctl enable mysqld
openbsdhost# rcctl start mysqld

Proceed to the secure installation :

openbsdhost# mysql_secure_installation

To configure MariaDB for Chyrp-Lite we need to connect to it and create the database and the user for it :

openbsdhost# mysql -u root
MariaDB >CREATE USER 'chyrpdbuser'@'localhost' IDENTIFIED BY 'password';
MariaDB >CREATE DATABASE chyrpdb;
MariaDB >GRANT ALL PRIVILEGES ON chyrpdb.* TO 'username'@'chyrpdbuser';
MariaDB >FLUSH PRIVILEGES;

Now our stack is ready to receive Chyrp-Lite.

Installing Chyrp-Lite :

Dowload the latest release of Chyrp-Lite at https://github.com/xenocrat/chyrp-lite/releases/

openbsdhost# wget https://github.com/xenocrat/chyrp-lite/archive/refs/tags/v2022.03.01.tar.gz
openbsdhost# tar -zxf v2022.03.01.tar.gz
openbsdhost# cd chyrp-lite-2022.03.01/
openbsdhost# mv * /var/www/htdocs/

Delete the “tools” folder and start installing Chyrp-Lite by visiting install.php at http://server-public-ip/install.php

The web page will ask you to adjust some folder permissions, you can do so and reload the webpage until you have no more permissions to adjust :

openbsdhost# chown www /var/www/htdocs/includes/

image

Depending your configuration, all optional fields can be ignored :

  • Adapter : should already be selected to MySQL.
  • Host : should have “localhost” by default. But I ran into issues that were resolved by setting to “127.0.0.1” instead.
  • Username: Chypr-Lite user that we created in MariaDB.
  • Password : password for the Chypr-Lite user in MariaDB.
  • Database : Chypr-Lite database that we created.
  • Chyrp URL : you can set your public IP or your domain name if you have one. We will not be covering anything related to setting your domain, enabling https etc. If you are setting a domain name you would need to redirect all type A DNS records to your web server’s public IP, this can be done in your registrar dashboard.

Admin account user name, password and email : this will be the user that you can use to log and manage your Chypr-Lite blog.

Upon submitting you will get a webpage confirming that the installation is completed and that you can delete the install.php file. After deleting that file you may log and start using your blog.

Recommended :

I recommend every once in a while to backup your "Upload" folder, the /include/config.json.php file and to save a dump of the Chypr-Lite MariaDB database in case your server crashes, if you want to move your web server to another VPS provider or update Chyrp-Lite.

Errata/Feedbacks can be sent to : said [at] nexoft [dot] fr