Joomla! 4.3 on OpenBSD 7.3: Install
Tags: joomla, php, cms, openbsd
Published: 2023-09-05 12:17:53

## Summary

[Joomla!](https://www.joomla.org/) is one of popular [PHP](https://www.php.net/) content management systems (aka CMS). It is good for portal-like websites as well as blogging platforms.
The first version was released in 2005 and, after long progress, the latest major one was done two years ago (on 2021-08-17).

This post shows how to install Joomla! with PHP/[PHP-FPM](https://www.php.net/manual/install.fpm.php) on [OpenBSD](https://www.openbsd.org/), the solid OS. All of them are the latest as of today.

### Environment

- OS: OpenBSD 7.3
- Database: [MariaDB](https://mariadb.com/) [10.9](https://mariadb.com/kb/en/changes-improvements-in-mariadb-109/)
- Web: OpenBSD's [httpd](https://man.openbsd.org/httpd.8)
  - managed with [`httpd.conf`](https://man.openbsd.org/httpd.conf.5)
- App: PHP [8.2](https://www.php.net/releases/8.2/)
  - PHP-FPM
- CMS: Joomla! [4.3](https://www.joomla.org/announcements/release-news/5882-joomla-4-3-0-stable-featuring-guided-tours.html).4

#### Reference posts

In case any of them are not done:

- Install [MariaDB](https://obsd.solutions/en/blog/2023/09/02/mariadb-109-on-openbsd-73-install/index.html)
- Set up [httpd](https://obsd.solutions/en/blog/2023/05/06/openbsd-httpd-73-web-server/index.html)
- Install [PHP](https://obsd.solutions/en/blog/2023/08/03/php-fpm-82-on-openbsd-73/index.html)

#### Notes on Joomla!'s system requirements

PHP 8.2 is not what is recommended officially by them today (See: their [Technical Requirements](https://downloads.joomla.org/technical-requirements)). It got, however, "improved support" in 4.3 release, which is described in their ["What’s new in Joomla 4.3.0 Stable?"](https://www.joomla.org/announcements/release-news/5882-joomla-4-3-0-stable-featuring-guided-tours.html). Therefore, PHP 8.2 should be a better option than 8.1 now. Besides, as to the other option, 8.0, its support will come to an end soon (See: PHP's [Supported Versions](https://www.php.net/supported-versions.php)).

## Tutorial

### Prepare database

Connect to the server with client tool (for example, running `mysql -u root -p`), and run:

```sql
-- create database
CREATE DATABASE <dbname> \
    CHARACTER SET utf8mb4 \
    COLLATE utf8mb4_unicode_ci;

-- create user
GRANT ALL PRIVILEGES \
    ON <dbname>.* \
    TO <dbuser>@'localhost' \
    IDENTIFIED BY '<dbpass>';

-- flush
FLUSH PRIVILEGES;
```

### Install and activate PHP extensions

Get [`mysqli`](https://www.php.net/manual/book.mysqli.php) for MariaDB connection:

```console
$ doas pkg_add php-mysqli
```

The output, my choice and the result were:

```console
quirks-6.122 signed on 2023-09-01T21:25:11Z
Ambiguous: choose package for php-mysqli
a	0: <None>
	1: php-mysqli-7.4.33
	2: php-mysqli-8.0.30
	3: php-mysqli-8.1.22
	4: php-mysqli-8.2.9
Your choice: 4
php-mysqli-8.2.9: ok
```

It is necessary to activate it (and also [`opcache`](https://www.php.net/manual/book.opcache.php)). Run:

```console
$ doas ln -s /etc/php-8.2.sample/* /etc/php-8.2/
```

Now they are activated:

```console
$ ls -l /etc/php-8.2
total 0
lrwxr-xr-x  1 root  wheel  30 Sep  2 10:09 mysqli.ini -> /etc/php-8.2.sample/mysqli.ini
lrwxr-xr-x  1 root  wheel  31 Sep  2 10:09 opcache.ini -> /etc/php-8.2.sample/opcache.ini
```

### Get Joomla! package

Suppose that **our working directory is `/var/www/joomla`**.

Run to download from their [releases](https://github.com/joomla/joomla-cms/releases) in GitHub:

```console
$ curl -LO https://github.com/joomla/joomla-cms/releases/download/4.3.4/Joomla_4.3.4-Stable-Full_Package.tar.gz
```

Decompress and extract it:

```console
$ tar xzf Joomla_4.3.4-Stable-Full_Package.tar.gz
```

Set permissions for web user:

```console
$ doas chown -R www:www ./*
```

### Add `httpd` (Web) server(s)

If you don't have the activated daemons of either httpd or PHP-FPM 8.2, you have to make them ready. (See [Reference posts](#reference-posts).)

If so, continue and add defition on Joomla! server(s):

```console
$ doas nvim /etc/httpd.conf
```

Write like below in it. Here, `<fqdn>` is up to you. `<chroot-parent-dir>` must be empty. (It is up to your working directory.) In addition, TLS configuration files are necessary to enable TLS (see below).

```apache
server "<fqdn>" {
        listen on egress tls port https
        tls {    
                certificate     "/etc/ssl/<fqdn>.crt"
                key             "/etc/ssl/private/<fqdn>.key"
        }
        log {
                access  "<fqdn>-access.log"
                error   "<fqdn>-error.log"
        }

        # it depends on your working directory under `/var/www` and `chroot` settings:
        root "<chroot-parent-dir>/joomla"
        directory index index.php

        location "/*.php" { 
                fastcgi socket "/run/php-fpm.sock"
        } 
        location "/*.php[/?]*" { 
                fastcgi socket "/run/php-fpm.sock"
        } 
}
```

Restart the daemon:

```console
$ doas rcctl restart httpd
httpd(ok)
httpd(ok)
```

Now we can access to Joomla!'s web installer with web browser. Connect to `https://<fqdn>/` !!

#### TLS configuration files

It is able to get them via requests to [Let's Encrypt](https://letsencrypt.org/) with [`acme-client`](https://man.openbsd.org/acme-client.1). (See: How to conifugre OpenBSD [acme-client](https://obsd.solutions/en/blog/2022/03/04/openbsd-acme-client-70-for-letsencrypt-certificates/index.html)).

Alternatively, you can get them as self-signed certificates with command lines such as:

```console
$ cd /etc/ssl

$ # [ consts ]
$ # case ksh:
$ export MY_DOMAIN="..."
$ export MY_COUNTRY_CODE="XX"
$ export MY_STATE="..."
$ export MY_ORGANIZATION="..."
$ # case fish:
$ # set -x MY_DOMAIN "..."; (...)

$ # [ generate ]
$ doas openssl req -newkey rsa:2048 -new -nodes -x509 -days 36500 -keyout private/$MY_DOMAIN.key -out $MY_DOMAIN.crt \
    -subj "/C=$MY_COUNTRY_CODE/ST=$MY_STATE/L=/O=$MY_ORGANIZATION/OU=/CN=$MY_DOMAIN"
$ doas chmod 400 private/$MY_DOMAIN.key

$ # return to your working directory
```

#### Server without TLS connection (Optional)

You may build another server which uses http instead of https (less secure):

```diff
# httpd.conf
<         listen on egress tls port https
<         tls {    
<                 certificate     "/etc/ssl/<fqdn>.crt"
<                 key             "/etc/ssl/private/<fqdn>.key"
<         }
>         listen on egress port http
```

#### Servers with and without TLS connection (Optional)

In addition, you can also redirect all http requests to https as needed:

```apache
# httpd.conf
server "<fqdn>" {
        listen on egress http
        # (...)
        block return 301 "https://$SERVER_NAME$REQUEST_URI"
}
server "<fqdn>" {
        listen on egress tls port https
        # (...)
}
```

### Set it up with web installer

All you have to do is just follow them. Well, in my case, the `<fqdn>` above was `192.168.122.175`.

Select default language and enter site name:

![joomla-4-install-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nw715nnhoaebnqsv5e13.png)

Create the system administrator:

![joomla-4-install-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2k1h7xjbbchn14dtft5w.png)

Enter database information, and clicking the button will start the actual installation:

![joomla-4-install-03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9awwb373pk6s8zfe9xa.png)

Success messages will be shown:

![joomla-4-install-04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2ml4y4n2qemlexm28gf.png)

### Validate installation

You will see the front page when `https://<fqdn>/` is accessed to:

![joomla-4-home-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/je3e8vepim9pwmwrjp27.png)

The admin entrance will be shown with `https://<fqdn>/administrator/` accessed to:

![joomla-4-admin-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rxij1spvpdxcfwkxcdd.png)

When authentication is successful, the admin panel will be shown:

![joomla-4-admin-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dtdscgmx9pwqxaeqc113.png)

## Conclusion

Now you are ready to build your website with the latest Joomla! Here shows an example about a very small step. Upload a media file in Media view:

![joomla-4-media-01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lezlqd6uqv1qnjka5vs.png)

Click "Upload" and choose a file. I tried one of the OpenBSD logos. It was successful :)

![joomla-4-media-02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7ohifdrd62423zqdqal.png)

As shown in this post, it is not tough work to build and serve PHP apps on OpenBSD, when httpd and PHP-FPM are configured. It's because their project and community support PHP and also components around web service.

🕊 Happy serving 💫