CageFS
Prerequisites
# CageFS requires:
# - CloudLinux OS
# - LVE manager installed
# - Kernel with LVE support
# Verify CloudLinux installation
cat /etc/cloudlinux-release
# Check LVE kernel
uname -r | grep lveInstallation
Install CageFS
# Install CageFS package
yum install cagefs -y
# Initialize CageFS
/usr/sbin/cagefsctl --init
# This creates necessary files and directories
# Takes 1-5 minutes depending on system sizeCreate CageFS Directories
# Create skeleton directory
mkdir -p /home/cagefs-skeleton
# Create symlink (if not automatically created)
ln -s /home/cagefs-skeleton /usr/share/cagefs-skeleton
# Create CageFS home directory
mkdir -p /home/cagefs
ln -s /home/cagefs /var/cagefsEnable CageFS
Enable for All Users
# Enable CageFS for all existing and new users
/usr/sbin/cagefsctl --enable-all
# This process may take several minutes
# Monitor progress: tail -f /var/log/cagefs-init.logEnable for Specific User
# Enable for single user
/usr/sbin/cagefsctl --enable username
# Disable for single user
/usr/sbin/cagefsctl --disable username
# List all enabled users
/usr/sbin/cagefsctl --listConfiguration
CageFS Configuration File
# Edit CageFS configuration
sudo nano /etc/cagefs/cagefs.conf
# Important settings:
# disable apache built-in php = 1
# path = /home/cagefs
# skel = /usr/share/cagefs-skeletonUpdate Skeleton Files
# Update CageFS skeleton with system files
/usr/sbin/cagefsctl --update-etc
# Update specific parts
/usr/sbin/cagefsctl --update-kernel
/usr/sbin/cagefsctl --update-filesService Management
# Start CageFS service
sudo systemctl start cagefs
# Stop CageFS service
sudo systemctl stop cagefs
# Restart CageFS
sudo systemctl restart cagefs
# Check service status
sudo systemctl status cagefs
# Enable on boot
sudo systemctl enable cagefsMonitoring
Check CageFS Status
# List all users with CageFS enabled
/usr/sbin/cagefsctl --list
# Get CageFS statistics
/usr/sbin/cagefsctl --stat
# View CageFS logs
tail -f /var/log/cagefs-init.logView CageFS Usage
# Check disk usage of CageFS
du -sh /home/cagefs
# Check individual user usage
du -sh /home/cagefs/username
# Check skeleton size
du -sh /usr/share/cagefs-skeletonRemounting CageFS
# Remount all CageFS users
/usr/sbin/cagefsctl --remount
# Useful after configuration changes
# Requires users to be logged out
# Check mount status
/usr/sbin/cagefsctl --mount-statusManaging Files in CageFS
Add Files to CageFS
# Make file available in all CageFS
# Edit /etc/cagefs/cagefs.conf
# Or use /etc/cagefs/cagefs.base.conf
# Add library:
# /lib/libmysqlclient.so.16
# Add binary:
# /usr/local/bin/custom-toolUpdate All CageFS
# Update all user environments
/usr/sbin/cagefsctl --remount
# Or individual update
/usr/sbin/cagefsctl --update-etc
# Then remount
/usr/sbin/cagefsctl --remountAdvanced Configuration
Custom PHP Versions in CageFS
# If using PHP Selector:
# 1. Install desired PHP versions
# 2. Update CageFS:
/usr/sbin/cagefsctl --update-etc
# 3. Users can select PHP version in DirectAdminDatabase Access in CageFS
# MySQL socket in CageFS
# Located at: /var/lib/mysql/mysql.sock
# Verify socket access
/usr/sbin/cagefsctl --stat | grep mysqlTroubleshooting
# Check CageFS errors
/usr/sbin/cagefsctl --sanity-check
# Repair CageFS
/usr/sbin/cagefsctl --repair
# Rebuild CageFS completely
/usr/sbin/cagefsctl --reinit
# Monitor for issues
tail -f /var/log/cagefs/*.log
# Check mount status
mount | grep cagefs
# Verify user environments
ls -la /var/cagefs/
ls -la /home/cagefs/Backup & Restore
# Backup CageFS configuration
sudo tar -czf cagefs-backup-$(date +%Y%m%d).tar.gz /etc/cagefs /home/cagefs-skeleton
# Backup CageFS data
sudo tar -czf cagefs-data-backup-$(date +%Y%m%d).tar.gz /var/cagefs
# Restore configuration
sudo tar -xzf cagefs-backup-20240101.tar.gz -C /
# Restore data
sudo tar -xzf cagefs-data-backup-20240101.tar.gz -C /Disable CageFS (if needed)
# Disable CageFS for all users
/usr/sbin/cagefsctl --disable-all
# Disable service
sudo systemctl disable cagefs
sudo systemctl stop cagefs
# Unmount all CageFS
/usr/sbin/cagefsctl --unmount-all
# Remove CageFS (optional)
yum remove cagefs -yPerformance Tips
# Monitor CageFS performance
/usr/sbin/cagefsctl --stat
# Optimize skeleton size
du -sh /usr/share/cagefs-skeleton
# Regular maintenance
# Schedule weekly CageFS updates:
0 2 * * 0 /usr/sbin/cagefsctl --remount
# Add to crontab:
crontab -eIntegration with DirectAdmin
# CageFS automatically integrates with DirectAdmin:
# 1. When user is created, CageFS is automatically enabled
# 2. When user is suspended, CageFS is unmounted
# 3. When user is deleted, CageFS environment is removed
# Manual integration:
# Admin Panel > DirectAdmin Settings > CageFS Integration
# Should show: CageFS is installed and enabledLimits and Restrictions
# CageFS provides isolation:
# - Each user can only see their own files
# - Users cannot see system files
# - Users cannot escape their home directory
# - Limits system resource access
# Combined with LVE limits (CloudLinux):
# - CPU limits
# - Memory limits
# - Process limits
# - I/O limits