Install the Rar/Unrar Binaries
Download the latest RAR packages for Linux x64 from rarlab.com. Note: These binaries are for x86 only. ARM is not supported. Extract the tar.gz package and copy the rar and unrar binaries to your /usr/local/bin directory:
wget https://www.rarlab.com/rar/rarlinux-x64-700.tar.gz
tar -zxvf rarlinux-x64-700.tar.gz
cd rar
cp rar unrar /usr/local/bin
Debian / Ubuntu
Debian / Ubuntu servers should also edit the file /etc/amavis/conf.d/01-debian and un-comment the non-free version and comment out the unrar-free entry. (The free version only supports older versions of .rar). After you are done the lines should look like this:
$unrar = ['rar', 'unrar']; #disabled (non-free, no security support)
#$unrar = ['unrar-free'];
Restart Amavis
// Centos/RHEL/CloudLinux/AlmaLinux
systemctl restart amavisd
// Debian/Ubuntu
systemctl restart amavis
Important
It is important that you always keep these binaries updated regularly as Rarlab releases new versions as older versions can contain security vulnerabilities. Versions below 6.12 contain a serious security path traversal vulnerability (CVE-2022-30333).