How to Enable PostgreSQL Support in CageFS on CloudLinux OS

June 27, 2025 / Servers, Hosting & Email

This article explains how to enable PostgreSQL support in CageFS on CloudLinux OS 6 and 7. It covers socket configuration, CageFS integration, and additional steps for cPanel servers to ensure PostgreSQL works correctly in a secure, isolated environment.

This applies to CloudLinux OS 6, CloudLinux OS 7, and cPanel servers.

Prerequisites:

  • Root access to the server
  • PostgreSQL installed from official CentOS/CloudLinux repositories
  • CageFS installed and configured

Follow the steps:

  1. CloudLinux OS 7
    PostgreSQL packages are unmodified from CentOS and work seamlessly with CageFS if properly mounted.

    1. Check CageFS version:
      Make sure you are using cagefs-5.5-6.34 or later, which mounts “/var/run/postgresql” by default.
    2. If PostgreSQL was installed after CageFS, do the following:
      echo “/var/run/postgresql” >> /etc/cagefs/cagefs.mp
      cagefsctl --remount-all
    3. PostgreSQL’s socket will now be visible inside CageFS.
  2. CloudLinux OS 6
    This version handles PostgreSQL sockets differently due to hardcoded paths in the PostgreSQL libraries.

    1. How it works:
      1. CloudLinux offers a custom PostgreSQL startup script that places the socket in “/var/run/postgres”.
      2. A symlink from “/tmp” to that socket ensures compatibility with PostgreSQL-based applications.
      3. CageFS automatically handles this symlink on a per-user basis.
    2. Steps:
      1.  Update PostgreSQL:
        Ensure you are running the latest version provided by CloudLinux.
      2.  Edit socket configuration:
        Open “/etc/sysconfig/postgres” and uncomment the following line:
        SOCK_DIR=/var/run/postgres
      3. Reconfigure CageFS:
        cagefsctl --reconfigure-cagefs
      4. Restart PostgreSQL:
        service postgresql restart
  3. Additional Configuration for cPanel Users
    If you are using cPanel, you must update the daily “tmpwatch” cron job to avoid it deleting the socket symlink.

    1. Open the cron script:
      nano /etc/cron.daily/tmpwatch
    2. Find the line:
      flags=-umc
    3. Change it to:
      flags=-umcl
    4. Save and exit the file.

This prevents the PostgreSQL symlink in “/tmp” from being removed during the daily cleanup.

This way, you can enable PostgreSQL support in CageFS on CloudLinux OS. However, if you require additional support, feel free to contact our support staff.

Managing CageFS access for users? Learn How to enable or disable CageFS for users in CloudLinux

Spread the love