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

  1. Navigate to http://downloads.mariadb.org/mariadb/repositories/
  2. Select the distro and the mirror
  3. Add the generated sources to /etc/apt/sources.list
  4. 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

  5. Run:

    apt-get update && apt-get upgrade

  6. 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

  1. 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.

  2. 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.

  3. Download mod_ruid2 source and unpack it. Run:

    wget link-to-source-file-from-sourceforge
    tar -xvjf downloaded-tar.bz2-source-file

  4. Navigate to the source and build it. Run:

    cd source-file-directory
    apxs2 -a -i -l cap -c mod_ruid2.c

    The ruid2 module will be built and installed automatically.

  5. Run:

    /etc/init.d/apache2 reload

    to load the module.

  6. 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.
  7. 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″

    ……..

  8. 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

VN:F [1.9.22_1171]
Rating: 9.5/10 (2 votes cast)
Installing MariaDB and mod_ruid2 on Debian Squeeze, 9.5 out of 10 based on 2 ratings

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

9 visitors online now
2 guests, 7 bots, 0 members
Max visitors today: 20 at 12:01 am UTC
This month: 33 at 10-24-2014 04:10 pm UTC
This year: 44 at 02-10-2014 11:09 am UTC
All time: 269 at 12-05-2012 07:53 am UTC