How to Install CloudLinux on a DirectAdmin Server

Convert a DirectAdmin server on AlmaLinux 9 to CloudLinux with cldeploy, switch CustomBuild to lsphp, set up CageFS and PHP Selector, and verify with cldiag.

Published
Updated
Reading time
4 min

CloudLinux is not installed from an ISO. You take a working AlmaLinux server, with DirectAdmin already on it, and convert it in place with one script and one reboot. This guide does that on AlmaLinux 9, then makes the two CustomBuild changes DirectAdmin needs, enables CageFS and PHP Selector, and checks the result. Allow an hour including the reboot.

Before you start

You need a server on AlmaLinux 9 (Rocky 9 and RHEL 9 also work; 8 and 10 convert to the matching CloudLinux major) with DirectAdmin installed and its accounts working. CloudLinux is x86-64 only.

You need a licence. Buy one at cloudlinux.com or start the trial, and note the activation key. If you bought an IP-based licence instead, the install command differs by one flag, shown below.

Take a backup first. Run Admin Level → Server Manager → Admin Backup/Transfer to a remote FTP or SFTP destination, and if the server is a VPS, take a snapshot as well. The conversion replaces the kernel and several system packages; it is well tested, but the reboot is the moment you want a way back.

Check free space. CageFS builds a skeleton filesystem of around 7 GB under /usr/share/cagefs-skeleton, on top of the packages the converter installs, so have at least 15 GB free on the root filesystem.

Run cldeploy

As root:

bash
wget https://repo.cloudlinux.com/cloudlinux/sources/cln/cldeploy
sh cldeploy -k YOUR-ACTIVATION-KEY

For an IP-based licence, use sh cldeploy -i instead of -k. The script registers the server with CloudLinux, swaps the AlmaLinux repositories for CloudLinux ones, installs the LVE kernel, lve-utils, lve-stats and lvemanager, and replaces the handful of packages that differ. It detects DirectAdmin and installs the panel plugin. Expect ten to twenty minutes, then a message telling you to reboot:

bash
reboot

Verify the kernel

After the server comes back:

bash
uname -r
cat /etc/cloudlinux-release

On CloudLinux 8 the kernel name contains lve, for example 4.18.0-…lve.el8; if it does not, the server booted the old kernel, so check what GRUB thinks the default is with grubby --default-kernel, set it to the CloudLinux one with grubby --set-default /boot/vmlinuz-<lve kernel> and reboot again. CloudLinux 9 and 10 run an unmodified AlmaLinux kernel, so the kernel name looks unchanged there; /etc/cloudlinux-release and the cldiag run below are the checks that matter.

Switch CustomBuild to lsphp

DirectAdmin's default PHP mode is PHP-FPM, and PHP Selector does not work with PHP-FPM on DirectAdmin. The supported mode is lsphp, which is CloudLinux's mod_lsapi: faster than PHP-FPM under shared-hosting load, with opcache per user, and the mode PHP Selector and CageFS expect. Tell CustomBuild about CloudLinux and switch the mode:

bash
cd /usr/local/directadmin/custombuild
./build update
./build set cloudlinux yes
./build set php1_mode lsphp
./build php n
./build rewrite_confs

If you run more than one PHP slot, set php2_mode (and so on) to lsphp as well before ./build php n. The rebuild takes a while; sites keep serving from the old handler until rewrite_confs switches them over.

This works with the apache and nginx_apache web server options. Keep one of those; the other web servers are outside this guide.

Enable CageFS and PHP Selector

CageFS gives each user a private view of the filesystem and is required by PHP Selector. Install it, build the skeleton and enable it for everyone:

bash
yum install cagefs
cagefsctl --init
cagefsctl --enable-all

--init is the slow step. Then install the alt-php packages that PHP Selector offers to users and push them into the skeleton:

bash
yum groupinstall alt-php
cagefsctl --force-update

What CageFS changes for users, and the things it can break, are in CageFS: what it does and how to enable it.

What appears in DirectAdmin

Log in to DirectAdmin at https://server1.example.com:2222 as admin. Under Admin Level → Extra Features there is a new CloudLinux Manager (older skins call it LVE Manager). Its tabs are Current Usage, Users, Statistics, Packages, Options and Selector. Nothing is limited yet beyond the defaults (100% CPU, 1 GB memory, 20 entry processes), and every existing account already has an LVE. Setting proper values per package is the next job, covered in setting LVE limits.

Log in as a user (Login as from the user list) and look under Advanced Features. Select PHP Version lets the user pick a PHP version and extensions; Resource Usage shows their LVE usage and faults. Neither needs anything from you.

Check everything with cldiag

CloudLinux ships a diagnostics tool that checks the kernel, licence, CageFS, PHP Selector, the LVE setup and the symlink protection in one go:

bash
cldiag --all

Every line should be OK. The common failure right after an install is a PHP Selector check complaining about the handler, which means php1_mode is still php-fpm; rerun the CustomBuild steps. If the licence check fails, clnreg_ks --force re-registers the server.

Going back

If you need to undo the conversion, the same tool does it:

bash
/usr/sbin/cldeploy -c
reboot

That restores the AlmaLinux repositories and removes the CloudLinux packages; on CloudLinux 8 you also remove the lve kernel and reinstall the stock one by hand. Then put CustomBuild back the way it was:

bash
cd /usr/local/directadmin/custombuild
./build set cloudlinux no
./build set php1_mode php-fpm
./build php n
./build rewrite_confs

Users lose their per-account PHP versions when PHP Selector goes, so check which versions people had chosen and set the equivalent per domain in DirectAdmin before you switch back. On a VPSPioneer managed VPS we do the conversion and the CustomBuild changes for you, as part of the service.

#cloudlinux#directadmin#installation#custombuild

Keep reading

More from CloudLinux

All guides

CloudLinux

CloudLinux PHP Selector: A PHP Version and Extensions Per Account

How CloudLinux PHP Selector gives each account its own PHP version, extensions and php.ini values, what it needs on DirectAdmin, and the CLI to manage it.

5 min read →

CloudLinux

MySQL Governor: Stop One Database From Slowing Everyone Down

How CloudLinux MySQL Governor tracks MariaDB load per user and throttles the heavy ones inside their LVE, with install steps, dbtop and dbctl limits explained.

4 min read →

CloudLinux

Node.js, Python and Ruby Selectors: Run Real Apps on CloudLinux

How the CloudLinux Node.js, Python and Ruby Selectors let shared hosting accounts run Express, Django or Rails apps through Passenger inside their own LVE.

5 min read →