How To: Install and Enable lsphp mod_lsapi for CloudLinux Plugin on InterWorx¶
Apache mod_lsapi is a module based on LiteSpeed Technologies API for PHP. It offers excellent PHP performance, and low memory footprint, coupled with great security and support for opcode caching.
LSAPI is a persistent php process handler which means faster and more stable dynamic web pages. When combined with opcode caching, it offers superior performance to Su_PHP.
LSPHP MOD_LSAPI is the only persistent opcode cache compatible PHP handler that fully supports the CloudLinux PHP version selector.
Full Cloudlinux LSAPI documentation can be found here.
Note
LSPHP MOD_LSAPI for Cloudlinux on Interworx requires a valid Cloudlinux license and install.
To Install Mod_LSAPI¶
Note
The following requires CloudLinux to already be installed. Instructions on how to do so can be found here.
Log in to the CLI as root, either via SSH or from the terminal
Run the following commands:
yum install liblsapi liblsapi-devel yum install mod_lsapi service httpd restart
To Manage LSAPI Globally¶
To Enable LSAPI Globally¶
Log in to the CLI as root, either via SSH or from the terminal
Run the following to create a global custom vhost PHP template, and automatically open the file:
~iworx/bin/config.pex --customize-template php/vhost-mod-suphp.tpl --for-global
Delete the IfModule mod_suphp.c section:
<IfModule mod_suphp.c> <FilesMatch \.php$> AddHandler x-httpd-php .php suPHP_AddHandler x-httpd-php .php </FilesMatch> suPHP_Engine On suPHP_UserGroup {$UNIX_USER} {$UNIX_USER} suPHP_ConfigPath {$PACKAGE_ROOT}/etc </IfModule>
Add the following to the template:
<IfModule lsapi_module> <FilesMatch "\.(php|php4|php5|php53|php54|php55|php56|php6|phtml)$"> AddType application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml AddHandler application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml </FilesMatch> </IfModule>
The full, edited template should look like the following:
{* This template file is a custom InterWorx template, initially copied from: /home/interworx/etc/templates/php/vhost-mod-suphp.tpl Please refer to the original file for more information. *} # iw-php-mode : system-mod-suphp DirectoryIndex {$Config->get('HTTPD_DIRECTORY_INDEX')} <IfModule lsapi_module> <FilesMatch "\.(php|php4|php5|php53|php54|php55|php56|php6|phtml)$"> AddType application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml AddHandler application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml </FilesMatch> </IfModule>
Save and exit the file
Run the following to update all existing vhosts:
~iworx/bin/httpd.pex --write-vhosts-all
Test the Apache configuration
httpd -t
Restart Apache
systemctl restart httpd
To Disable LSAPI and Restore the Default Global PHP Template¶
Delete the custom template file
rm /home/interworx/etc/templates/custom-globalphp/vhost-mod-suphp.tpl
Run the follwing to update all existing vhost:
~iworx/bin/httpd.pex --sync-vhosts-all
Restart Apache
systemctl restart httpd
To Mange LSAPI For a Single Domain¶
To Enable LSAPI For a Single Domain¶
Log in to the CLI as root, either via SSH or from the terminal
Run the following to create a single domain custom vhost PHP template, and automatically open the file. Replace {domain} with the domain the template should refer to:
~iworx/bin/config.pex --customize-template php/vhost-mod-suphp.tpl --for-domain {domain}
Delete the IfModule mod_suphp.c section:
<IfModule mod_suphp.c> <FilesMatch \.php$> AddHandler x-httpd-php .php suPHP_AddHandler x-httpd-php .php </FilesMatch> suPHP_Engine On suPHP_UserGroup {$UNIX_USER} {$UNIX_USER} suPHP_ConfigPath {$PACKAGE_ROOT}/etc </IfModule>
Add the following to the template:
<IfModule lsapi_module> <FilesMatch "\.(php|php4|php5|php53|php54|php55|php56|php6|phtml)$"> AddType application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml AddHandler application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml </FilesMatch> </IfModule>
The full, edited template should look like the following:
{* This template file is a custom InterWorx template, initially copied from: /home/interworx/etc/templates/php/vhost-mod-suphp.tpl Please refer to the original file for more information. *} # iw-php-mode : system-mod-suphp DirectoryIndex {$Config->get('HTTPD_DIRECTORY_INDEX')} <IfModule lsapi_module> <FilesMatch "\.(php|php4|php5|php53|php54|php55|php56|php6|phtml)$"> AddType application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml AddHandler application/x-httpd-lsphp .php .php4 .php5 .php53 .php54 .php55 .php56 .php6 .phtml </FilesMatch> </IfModule>
Save and exit the file
Run the following to update the vhost for the domain, replacing {domain} with the domain of the vhost file:
~iworx/bin/httpd.pex --write-vhost --domain {domain}
Test the Apache configuration
httpd -t
Restart Apache
systemctl restart httpd
To Disable LSAPI and Restore the Default PHP Template For the Domain¶
Delete the custom template file, replacing {domain} with the domain the template referred to
rm /home/interworx/etc/templates/custom-domain/{domain}/php/vhost-mod-suphp.tpl
Run the follwing to update the vhost, replacing {domain} with the domain of the vhost file:
~iworx/bin/httpd.pex --sync-one-vhost --domain {domain}
Restart Apache
systemctl restart httpd