Server setup

The below instructions are working only on AlmaLinux 9.

For other operating systems, they need to be adapted accordingly.

Starting point

A server with AlmaLinux 9 freshly installed, up to date and with root access.

Update OS

sudo dnf update -y

Create a new user with sudo permissions

sudo useradd dotkernel
sudo passwd dotkernel
sudo usermod -aG wheel dotkernel

Reboot server.

SSH into the server as dotkernel.

Install various utilities

sudo dnf install -y dnf-utils
sudo dnf install zip unzip socat wget

PHP

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module enable php:remi-8.4
sudo dnf install -y php php-cli php-common php-intl

Start PHP-FPM

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Install and verify swoole

sudo dnf install php-pecl-swoole6
php -i | grep swoole

Valkey

sudo dnf install valkey
sudo systemctl enable valkey
sudo systemctl start valkey
sudo valkey-cli ping

Valkey PHP module

sudo dnf install php-pecl-redis

Make sure that the module is installed.

php -i | grep redis

Git

sudo dnf install git

Composer

wget https://getcomposer.org/installer -O composer-installer.php
sudo chmod 777 /usr/local/bin
php composer-installer.php --filename=composer --install-dir=/usr/local/bin

Firewall setup

To add a minimum level of security, a firewall needs to be installed and allow connections from outside only to certain ports, from certain IPs.

Firewall setup is not mandatory

sudo dnf install firewalld
sudo systemctl enable firewalld

Before starting the firewall, make sure you will not get locked outside:

sudo firewall-offline-cmd --zone=public --add-port=22/tcp --permanent

Then enable the firewall:

sudo systemctl start firewalld

By default, Swoole runs on port 8556. You can change that in the configuration file.

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="YOUR_IP_ADDRESS" port port="8556" protocol="tcp" accept'
sudo firewall-cmd --reload

NOW THE SERVER IS READY