How Can We Help?
Enable CageFS for OpenLiteSpeed.
Before starting, please verify that CloudLinux and CageFS are properly installed and initiated:
[root@test ~]# cat /etc/redhat-release
CloudLinux release 7.6 (Vladimir Lyakhov)
[root@test ~]# /usr/sbin/cagefsctl --display-user-mode
Mode: Disable All
Step 1
Log into the WebAdmin Console via https://IP:7080
. Navigate to Server Configuration > General > Server Process. Set CloudLinux to CageFS
, save, and restart OpenLiteSpeed.
Step 2
Add the user into CageFS with this command, making sure to replace example
with your PHP userid:
[root@test ~]# /usr/sbin/cagefsctl --enable example
Updating users ...
And that’s it!
How to Verify if CageFS Works
For demonstration purposes, create a test.txt
outside of the user home folder.
[root@test ~]# echo "CageFS test" > /test.txt
[root@test ~]# cat /test.txt
CageFS test
Create a PHP file to read it:
cat > /home/example.com/public_html/test.php << 'EOF'
<?php
$myfile = fopen("/test.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("test.txt"));
fclose($myfile);
?>
EOF
[root@test ~]# curl -XGET http://example.com/test.php
CageFS test
Enable CageFS options in the WebAdmin Console and restart OpenLiteSpeed.
[root@test ~]# curl -XGET http://example.com/test.php
Unable to open file!