Issue
This is a practical manual of setting up Apache + mod_lsapi + CageFS + PHP Selector on a server with no panel installed.
Environment
- CloudLinux OS 6(h)/7(h)/8
- No panel
Solution
It is assumed that our system has been converted and loaded with CloudLinux kernel. Since PHP Selector installation requires CageFS and LVE Manager installed in the system, let's start with CageFS installation:
yum install cagefs
Next we'll need to install LVE Manager:
yum install lvemanager
Then install Apache and native PHP:
yum install httpd
yum install php-cli
Then install mod_lsapi:
yum install liblsapi liblsapi-devel
yum install mod_lsapi
Finally, install PHP Selector:
yum groupinstall alt-php
If there is a php.conf file in Apache's conf.d, which is usually brought by the php or php-fpm package, then it should be deleted or renamed.
For example, php.conf can be renamed into php.conf.NO
Now let's configure components. Initialize CageFS and enable for all users:
cagefsctl --init
cagefsctl --enable-all
Initialize mod_lsapi (few errors will appear, this is normal, please ignore them):
/usr/bin/switch_mod_lsapi --setup
Enable mod_lsapi PHP handler:
sed -i 's/#AddType/AddType/' /etc/httpd/conf.d/lsapi.conf
Update CageFS skeleton:
cagefsctl --force-update
We also need to open access to 80 port:
firewall-cmd --zone=public --permanent --add-port=80/tcp
firewall-cmd --reload
Now we are ready to set up a website. Let's create user first, Change home directory permissions to allow httpd access it and create require directories
adduser cltest1
chmod 711 /home/cltest1
su cltest1 -c "mkdir ~/public_html{,/logs,/cgi-bin}"
Finally, let's add website to Apache configuration. Create a file /etc/httpd/conf.d/vhosts.conf with the following contents:
<VirtualHost *:80> ServerName default DocumentRoot /var/www/html </VirtualHost> <VirtualHost *:80> ServerAdmin cltest1@example.com DocumentRoot "/home/cltest1/public_html" ServerName example.com ServerAlias www.example.com ErrorLog "/home/cltest1/public_html/logs/error.log" CustomLog "/home/cltest1/public_html/logs/access.log" common ScriptAlias /cgi-bin/ "/home/cltest1/public_html/cgi-bin/" SuexecUserGroup cltest1 cltest1 <Directory "/home/cltest1"> AllowOverride All </Directory> <Directory "/home/cltest1/public_html/cgi-bin"> AllowOverride None Options None </Directory> </VirtualHost>
Please note, first VirtualHost must be defined only once, it will be used for requests that didn't match any other VirtualHost.
Make sure that mod_php is disabled since it's not compatible with PHP Selector:
apachectl -M | grep php
You need to disable it if you see php7_module or a similar module in the output.
Everything is ready now. Restart Apache httpd:
systemctl restart httpd.service
You can now use selectorctl utility to select PHP versions for your users.
Comments
0 comments
Please sign in to leave a comment.