Author Topic: Varnish does not install with cwp-el9-latest - Fixed  (Read 110 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Varnish does not install with cwp-el9-latest - Fixed
« on: June 03, 2026, 12:04:05 AM »
Hello, I recently installed CWP on AlmaLinux 9 (https://dl1.centos-webpanel.com/files/cwp-el9-latest) and to my surprise, when I go to WebServers_manage and select Nginx & Varnish & Apache, Varnish NEVER installs. By analyzing cwpsrv with stress-ng, I was able to detect exactly where the error is.

The strace accurately reveals why the installer was failing silently:

The panel tries to download a non-existent script (varnish.sh returns a 404 at https://dl1.centos-webpanel.com/files/s_scripts/el9/varnish.sh).

Then, it tries to apply a sed command to /etc/varnish/varnish.params. This throws an "Exit Code 2" because Varnish no longer uses that file in AlmaLinux 9.

Finally, it crashes when trying to clean /etc/varnish/conf.d/vhosts because the directory simply does not exist.

In the end, PHP generates the .vcl files, but the daemon is never actually installed or started.

The following EL8 script logic was used as a reference to build the fix: https://dl1.centos-webpanel.com/files/s_scripts/el8/varnish.sh



Code: [Select]
# 1. Install repositories and clean dependencies
dnf -y install epel-release jemalloc --enablerepo=epel
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish64/script.rpm.sh | bash
dnf -y module disable varnish
dnf -y install varnish

# 2. Build the directory structure that the panel assumes exists
mkdir -p /etc/varnish/conf.d/vhosts
touch /etc/varnish/conf.d/vhosts.conf

# 3. Patch the CWP bug (The phantom file)
# We create this file to prevent the panel's internal "sed" from throwing Exit Code 2
echo "VARNISH_LISTEN_PORT=82" > /etc/varnish/varnish.params

# 4. Modify the master port at the Systemd level (The definitive way)
if [ -e "/usr/lib/systemd/system/varnish.service" ]; then
    sed -i "s|6081|82|g" /usr/lib/systemd/system/varnish.service
    systemctl daemon-reload
fi

# 5. Force PHP to regenerate the vHosts with the repaired structure
sh /scripts/cwpsrv_rebuild_user_conf

# 6. Bring up the proxy chain in order
systemctl enable --now varnish
systemctl restart httpd
systemctl restart varnish
systemctl restart nginx

I hope they update WebServers_manage

Offline
*****
Re: Varnish does not install with cwp-el9-latest - Fixed
« Reply #1 on: June 03, 2026, 03:33:32 AM »
Thanks for that!
But be advised that CWP's EL9 support is only in beta, so consider it a bug/incompatibility. AlmaLinux 8 is the current recommended disto to use with CWP for FULL compatibility. But glad you were able to produce a workaround for the sake of the community!

Offline
*
Re: Varnish does not install with cwp-el9-latest - Fixed
« Reply #2 on: June 04, 2026, 05:52:28 AM »


It doesn't say it's in beta; in fact, they recommend AlmaLinux versions 8 and 9.
Regards.

Offline
*****
Re: Varnish does not install with cwp-el9-latest - Fixed
« Reply #3 on: June 04, 2026, 11:51:06 AM »
Good to know! I don't watch that page since I'm not doing new server installations on a regular basis. I was reporting the last info I had, which is about 6 mo old.