Installing MariaDB and mod_ruid2 on Debian Squeeze
This is a short post on how I replaced MySQL with MariaDB and then installed mod_ruid2 as an alternative to php-fcgi (for Apache), for enhanced performance on Debian Squeeze.
Installing MariaDB
- Navigate to http://downloads.mariadb.org/mariadb/repositories/
- Select the distro and the mirror
- Add the generated sources to /etc/apt/sources.list
- Import the GPG keys. Run:
apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
(all on one line)
The output should be as follows:
Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /etc/apt/secring.gpg –trustdb-name /etc/apt/trustdb.gpg –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –recv-keys –keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
gpg: requesting key 1BB943DB from hkp server keyserver.ubuntu.com
gpg: key 1BB943DB: public key “Daniel Bartholomew (Monty Program signing key)[email protected]>” imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 - Run:
apt-get update && apt-get upgrade
- Install the mariadb server. Run:
aptitude install mariadb-server
This will remove all installed mysql packages and replace them with the equivalent mariadb packages.
MariaDB is now installed and running.
Read through the MariaDB site for optimizing performance.
Installing mod_ruid2
- Run:
apache2 -V
and note down the type of apache MPM that is installed – whether prefork or threaded.
For e.g. on my server:
root@host:~# apache2 -V
Server version: Apache/2.2.16 (Debian)
Server built: Apr 1 2012 06:40:08
Server’s Module Magic Number: 20051115:24
Server loaded: APR 1.4.2, APR-Util 1.3.9
Compiled using: APR 1.4.2, APR-Util 1.3.9
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)Mine is a Prefork MPM.
- Install the development libraries and the compiler. Run:
aptitude install build-essential apache2-prefork-dev libcap-dev
Note: If your MPM is threaded, replace apache2-prefork-dev with apache2-threaded-dev in the command above.
- Download mod_ruid2 source and unpack it. Run:
wget link-to-source-file-from-sourceforge
tar -xvjf downloaded-tar.bz2-source-file - Navigate to the source and build it. Run:
cd source-file-directory
apxs2 -a -i -l cap -c mod_ruid2.cThe ruid2 module will be built and installed automatically.
- Run:
/etc/init.d/apache2 reload
to load the module.
- Ensure that php for the virtual host for which you want to use ruid2, is served through mod_php and not through fcgi. To do this in viritualmin, set the PHP script execution mode to mod_php for the virtual domain.
- Next, edit the relevant virtual host configuration file and add the ruid2 configuration as in the following example:
SuexecUserGroup “#1001″ “#1001″
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/example/public_html
ErrorLog /var/log/virtualmin/example.com_error_log
CustomLog /var/log/virtualmin/example.com_access_log combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
RMode config
RUidGid “#1001″ “#1001″
…….. - Run:
/etc/init.d/apache2 graceful
to reload the changes.
Now, for the edited virtual host, ruid2 will execute PHP as the specified user and group.
ruid2 works fine for me. The only caveat is with Virtualmin. Since Virtualmin does not support mod_ruid2 yet, any changes made through virtualmin for the virtualhost, overwrite the changes made in the configuration. We need to manually add the ruid2 directives again.
– Wirtten by Michael R. M. David
Installing MariaDB and mod_ruid2 on Debian Squeeze,