Wednesday, 1 February 2012

How to install the mod_ruid2 cpanel

The mod_ruid2 module is a suexec module for Apache 2.0 that provides performance similar that of mod_php with the security of suphp. This module allows PHP applications to run as the user, instead of as the user nobody in a manner similar to suphp.

However, mod_ruid2 is incompatible with some EasyApache modules, such as FastCGI, mod_cache, mod_disk_cache, mod_mem_cache, and ModMono. While mod_ruid2 may be ideal for many environments, cPanel recommends testing and verification that it is appropriate for your configuration. Generally, mod_ruid2 is not considered to be production-worthy.

The latest release of EasyApache includes improvements to several third-party libraries and utilities. Updates to EasyApache 3.11.2 include support for modruid2 latest version.

You can simply follow these steps to install mod_ruid2 manually with cpanel server.

yum -y install libcap-devel


The rest is just like those other threads but using the requisite module name and location:

cd /root
wget http://downloads.sourceforge.net/project/mod-ruid/mod_ruid2/mod_ruid2-0.9.4.tar.bz2
tar xvfj mod_ruid2-0.9.4.tar.bz2
cd mod_ruid2-0.9.4
apxs -a -i -l cap -c mod_ruid2.c


After doing the above, it will then put a "LoadModule" into /usr/local/apache/conf/httpd.conf file:

LoadModule ruid2_module modules/mod_ruid2.so


The module can cause conflicts during EasyApache build, so I would suggest moving it and distilling the include. First, remove the "LoadModule" line mentioned above from /usr/local/apache/conf/httpd.conf, then run these commands:

echo "LoadModule ruid2_module modules/mod_ruid2.so" >> /usr/local/apache/conf/includes/pre_main_global.conf
cp /usr/local/apache/conf/httpd/conf /usr/local/apache/conf/httpd.conf.bak110826
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart


Now, copy the mod_ruid2.so file to /root to save a copy of it, since future /scripts/easyapache recompiles will move the file out of /usr/local/apache/modules folder:

cp /usr/local/apache/modules/mod_ruid2.so /root


Now, before you run /scripts/easyapache in the future, create these files:

nano /scripts/preeasyapache


Place the following content into the file:

#!/bin/bash

sed -i 's/LoadModule ruid2_module/#LoadModule ruid2_module/g' /usr/local/apache/conf/includes/pre_main_global.conf


Next, create this file:

vi /scripts/posteasyapache


Place the following content into the file:

#!/bin/bash

cp /root/mod_ruid2.so /usr/local/apache/modules/
sed -i 's/#LoadModule ruid2_module/LoadModule ruid2_module/g' /usr/local/apache/conf/includes/pre_main_global.conf
/etc/init.d/httpd restart


The first script comments out the LoadModule in /usr/local/apache/conf/includes/pre_main_global.conf at the beginning of the Apache build. The second script copies mod_ruid2.so back into /usr/local/apache/modules folder, uncomments the LoadModule, and restarts Apache at the end of the build.

After saving these files, ensure they can execute:

chmod +x /scripts/preeasyapache
chmod +x /scripts/posteasyapache

No comments:

Post a Comment