How to install mod_lsapi for apache without running CloudLinux
mod_lsapi was specially developed by CloudLinux to run as an apache module. The module is based on LiteSpeed Technologies API for PHP, Python and Ruby. Compared to the traditional mod_php module it offers excelent PHP performance, great security and support for opcode caching. More, the memory consumption is really low.
You can find a complete list of specs and details on CloudLinux Documentation:
According to CloudLinux the requirements to run mod_lsapi are as follows:
– linux CentOS + CloudLinux
– Apache compiled with SuExec support
– mod_ruid2 has to be disabled
– apache itk has to be disabled
Since I was curios to test it and I didn’t want to use on our production servers which have CloudLinux installed, I tried to install it on a regular CentOS 6.7 machine (no CloudLinux installed or running).
And I did it!
mod_lsapi: Step by step installation instructions:
Step 1) download the source code:
# cd ~
# wget http://repo.cloudlinux.com/cloudlinux/sources/da/mod_lsapi.tar.gz
Step 2) download the .rpm files needed for dependencies in order to be able to compile mod_lsapi from source
# wget http://club3d.ro/liblsapi-0.3-15.el6.cloudlinux.x86_64.rpm
# wget http://club3d.ro/liblsapi-devel-0.3-15.el6.cloudlinux.x86_64.rpm
Step 3) check if you have installed cmake (needed to compile); if not please install cmake using:
# yum -y cmake
Step 4) extract files from archive, compile, install plugin
# tar zxvf mod_lsapi.tar.gz
# cd mod_lsapi-0.3-15/
# cmake .
# make install
# cp conf/mod_lsapi.conf /etc/httpd/conf.d/
Step 5) Install and configure PHP Support for LiteSpeed
# yum -y install php-litespeed
# cp /usr/bin/lsphp /usr/local/bin/lsphp
# chmod 755 /usr/bin/lsphp /usr/local/bin/lsphp
# chown apache:apache /usr/bin/lsphp /usr/local/bin/lsphp
Step 6) Create a temporary directory for lsphp
# mkdir /tmp/mod_lsapi; chown apache:apache /tmp/mod_lsapi
Step 7) Be sure that your apache server is running as apache/apache (user/group). You can check that by looking in /etc/httpd/conf/httpd.conf.
Step 8) If your website files are in /var/www/html let’s say and they have different owner/group than apache:apache set them accordingly
# chown apache:apache /var/www/html/ -R
Step 9) Disable mod_php or other settings for php (I was using mod_php so I had to disable the module loading into apache)
# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disabled
Step 10) Modify some settings for the lsapi module (/etc/httpd/conf.d/mod_lsapi.conf)
# uncomment AddType application/x-httpd-lsphp .php5 .php4 .php .php3 .php2 .phtml
# replace the standard settings for lsapi_user_group with lsapi_user_group apache apache
# uncomment lsapi_socket_path /tmp/mod_lsapi
Save the file when you’re done.
Step 11) Restart apache
# /etc/init.d/httpd restart
In order to check if you have a running php config, check your php information in a web browser.
cat > /var/www/html/info.php
<?php phpinfo(); ?>
CTRL+C (to save the file)
chown apache:apache /var/www/html/info.php
Point your web browser to http://your_server_ip_or_hostname/info.php
You should see something like this: Server API LiteSpeed V6.8