Installing DTC With Apache 2, PHP 5, MySQL 5 and others

Note: updated for version 0.24.5, as it was really outdated.

Note2: this page is highly outdated as the default for DTC is now Apache 2, PHP 5 and MySQL 5. You'd better go away from this page, unless you know what you are doing.

BIG WARNING HERE

If you want to use MySQL server 5.0 from the backports, and php5 from same source, please be aware that by default, the password auth thing changed. You HAVE to ask for the old password thing. Here is the my.cnf:

   [mysqld]
   old_passwords = true # inserted by debconf

If it's not like that, please do dpkg-reconfigure mysql-server-5.0 to resolve the issue, or edit your my.cnf and restart the server. Do that BEFORE you setup the control panel.

Also, from now on, the CVS version will NOT ask you if you want to change the MySQL root password, as this is a Debian requirement. Please change this password yourself BEFORE you setup the control panel.

You've been warned, now you can read the rest and try...

1. For what operating system?

This document is written for Debian users. That being said, many things written here apply to other distributions. The control panel itself is well written, and don't care to use MySQL 3, 4, 5, or php 4 or 5, or even apache 1.3 or 2. The problems are distribution dependent only (sometimes php4 or MySQL 5 is not available).

Note that if you use a version of them panel >= 0.25.0-1 (at the time of writting, 0.24.5 is current stable), and if php5 and MySQL 5 is available on your distribution (which is the case under SID), then it's going to setup by default with php5 and MySQL 5.

2. What package to choose?

First of all, if you need a specific version of php, we do not suggest you to use the one from dotdeb.org (I cannot stress it more: THESE PACKAGES ARE BAD, don't use them). Use the ones from backports.org, they are of a lot better quality, and often upgraded. If you care about security, this is the way to go.

3. mod_log_sql

First of all, if you are using apache2, you MUST do apt-get remove libapache-mod-log-sql. If DTC was installed before, it will remove it, but it's SAFE to do so as it wont destroy the DTC database (when reinstalling the panel, it will reuse the database and debconf values).

Then, if you used a php version that is NOT the standard one in Sarge, you MIGHT have a problem running both mod_log_sql and php-mysql at the same time. mod_log_sql_mysql uses the mysql C API, as well as mod_php for apache. They both link against the same library using the same function names. Because of that, they have to be both linked against the same libmysqlclient, otherwise apache will crash. This is absolutly normal, and the authors of both php and mod_sql are not to be blamed. For this reason, you have to take a particular care about what version to use according to your setup.

To know with what mysql API version your php-mysql package have been compiled-in, you can type:

    ldd /usr/lib/php4/20020429/mysql.so | grep mysqlclient

Note that of course, you need to find the correct path for your mysql.so php library.

Here is the corresponding table so you know the version to use:

    libmysqlclient.so.10 -> mysql 3.23
    libmysqlclient.so.12 -> mysql 4.0
    libmysqlclient.so.14 -> mysql 4.1
    libmysqlclient.so.15 -> mysql 5

If your php-mysql is not linked with mysql 4.0, then you CAN'T use the mod_log_sql version that we provide in our debian repository, you WILL have to compile it yourself.

To do so, you need to apt-get install build-essential and libmysqlclientXX-dev that correspond to your php-mysql, with XX being the numbers we just described.

Let's say you want to compile and install mod_log_sql for MySQL 5 and apache2. Here is how:

    # Checkout libapache-mod-log-sql from GPLHost cvs
    cvs -d :pserver:anonymous@gplhost.com:/var/lib/cvs checkout libapache-mod-log-sql
    # Compile the package
    cd libapache-mod-log-sql
    dpkg-buildpackage -rfakeroot (this will buid for BOTH apache 1.3 and apache 2)
    # Install the compiled package
    cd ..
    dpkg -i libapache2-mod-log-sql-mysql_1.100-4_i386.deb libapache2-mod-log-sql_1.100-4_i386.deb

Because there are too much combinaisons, we can't compile mod_log_sql for all setup (i386, amd64, with mysql 4.0, 4.1, 5: that would make about 6 different binary versions to compile and maintain...). Hopefully, libapache-mod-log-sql is now in SID directly, so it will soon not be a problem.

4. Setting up the panel and the rest

The rest of the setup is quite the same as the one described here Debian Express Setup.

The current stable version (0.24.5) DOES work with mysql 5, php5 and apache2. But the dependencies in dtc are made with priority to php4. That means that you have to insist on having php5 by installing them BY HAND and BEFORE the panel.

Also, squirrelmail will have dependencies to php4. You can get rid of it by doing this:

- apt-get source squirrelmail squirrelmail-locales - edit debian/control Depends line and add php5 - rebuild with dpkg-buildpackage (of course you need dpkg-dev and build-essential)

The current CVS version (at least version 0.25) makes mysql5, php5 and apache2 as priority: it's the opposite way.

Also, don't forget that under sarge, there is still a problem loading the mysql.so / gd.so php library. So in many case, you will have to dpkg-reconfigure php4-mysql (or php5-mysql) and same for gd, so it loads the lib in the php.ini (you can also check by hand that it has mysql.so and gd.so installed in). Note this is a KNOWN BUG in Sarge (I wrote to the author of the package) and that our job is NOT to fix the distribution itself (so don't complain to the autors of the panel).

Last trick, before you install (because the installer goes in the wrong folder): - mkdir /etc/php4 - cd /etc/php4 - ln -s ../php5/cli cli

Once setup, I suggest that you change the part that restarts apache2 by the one in current CVS (in dtc/admin/cron.php) as current stable don't do it very well.

Here is the new code that you should use to replace the existing one:

        if($return_var == false){
                echo "Config is OK : restarting Apache\n";
                echo "$APACHECTL stop\n";
                system("$APACHECTL stop");
                sleep(1);
                $ctl_retry = 0;
                while( is_file("$conf_generated_file_path/apache.pid") && $ctl_retry++ < 15){
                        echo "Warning: apache not stoped, will check and maybe retry in 2 seconds...";
                        echo "2...";sleep(1);echo "1...";sleep(1);echo "0";
                        clearstatcache();
                        if( is_file("$conf_generated_file_path/apache.pid") ){
                                echo "...retrying!\n";
                                $ctl_return = system("$APACHECTL stop", $return_var);
                        }else{
                                echo "...ok!\n";
                        }
                }
                clearstatcache();

                $ctl_return = system("$APACHECTL start");
                clearstatcache();
                sleep(1);
                $ctl_retry = 0;
                // Check that apache is really started, because experience showed sometimes it's not !!!
                //while( strstr($ctl_return,"httpd started") == false && $ctl_retry++ < 15){
                // This new version should work on OS where apachectl start is quiet
                while( !is_file("$conf_generated_file_path/apache.pid") && $ctl_retry++ < 15){
                        echo "Warning: apache not started, will check and maybe retry in 2 seconds...";
                        echo "2...";sleep(1);echo "1...";sleep(1);echo "0";
                        clearstatcache();
                        if( !is_file("$conf_generated_file_path/apache.pid") ){
                                echo "...retrying!\n";
                                $ctl_return = system("$APACHECTL start", $return_var);
                        }else{
                                echo "...ok!\n";
                        }
                }
                // change to graceful apache restart, rather than a hard stop and start
                // WARNING !!! Experience showed that it doesn't work sometimes !!!
                //system("$APACHECTL graceful");
        }else{

5. Next versions

Note that as of time of writting, the current stable version has those problems, but they are all fixed in the current CVS (version > 0.25). If current stable is 0.25 when you read this, then you have read for nothing, all is fixed.

Last thing, it is NOT supported to switch back from version >= 0.25 to so something lower. You will encounter some problems with uid gid set to dtc dtcgrp instead of nobody nogroup in both configuration files, the hosted files and in the database.

6. Detailed install instructions

  1. base install of debian sarge
  2. Add contrib to the /etc/apt/sources.list to your normal debian mirror (for msttcorefonts)
  3. apt-get install cvs fakeroot build-essential
  4. As per http://www.backports.org/dokuwiki/doku.php?id=instructions add sources.list for backports.org
  5. Add also deb-src http://www.backports.org/debian sarge-backports main contrib non-free
  6. apt-get -t sarge-backports install mysql-server
  7. apt-get -t sarge-backports install libmysqlclient15-dev
  8. apt-get -t sarge-backports source php5-mysql
  9. edit the dependancy so that it depends on libmysqlclient15-dev and not libmysqlclient12-dev
  10. install build dependancies:
	apt-get install apache2-prefork-dev autoconf automake1.4 chrpath debhelper firebird2-dev freetds-dev libapr0-dev libbz2-dev libc-client-dev libcurl3-dev libdb4.2-dev libexpat1-dev libfreetype6-dev libgcrypt11-dev libgd2-xpm-dev libjpeg62-dev libkrb5-dev libldap2-dev libmcrypt-dev libmhash-dev libncurses5-dev libpam0g-dev libpcre3-dev libpng12-dev postgresql-dev libpspell-dev librecode-dev libsnmp5-dev libsqlite3-dev libsqlite0-dev libssl-dev libt1-dev libtidy-dev libtool libwrap0-dev libxmltok1-dev libxml2-dev libxslt1-dev re2c unixodbc-dev libpcre3-dev apache-dev
	apt-get -t sarge-backports install libpcre3-dev
  1. apt-get install apache2-mpm-prefork
  2. Download the following deb files from http://tusker.sg/debs/ then install them: dpkg -i php5-mysql_5.2.0-8~bpo.2_i386.deb php5-common_5.2.0-8~bpo.2_i386.deb php5_5.2.0-8~bpo.2_all.deb libapache2-mod-php5_5.2.0-8~bpo.2_i386.deb php5-cgi_5.2.0-8~bpo.2_i386.deb
  3. Install pre-req to build libapache-mod-log-sql: apt-get install libdbi0-dev dpatch
  4. Install pre-req to build dtc: apt-get -t sarge-backports install debhelper
  5. As a user, grab the latest CVS of mod_log_sql and dtc:
	a) cvs -d :pserver:anonymous@gplhost.com:/var/lib/cvs checkout libapache-mod-log-sql
	b) cvs -d :pserver:anonymous@gplhost.com:/var/lib/cvs checkout dtc
	c) cvs -d :pserver:anonymous@gplhost.com:/var/lib/cvs checkout php-crypt-cbc
	d) cvs -d :pserver:anonymous@gplhost.com:/var/lib/cvs checkout sbox
  1. cd libapache-mod-log-sql; dpkg-buildpackage -rfakeroot
  2. cd dtc; dpkg-buildpackage -rfakeroot
  3. cd php-crypt-cbc; dpkg-buildpackage -rfakeroot
  4. cd sbox; dpkg-buildpackage -rfakeroot
  5. As root again: dpkg -i libapache2-mod-log-sql_1.100-8_i386.deb libapache2-mod-log-sql-mysql_1.100-8_i386.deb
  6. Install squirrelmail that can depends on php5: apt-get -t sarge-backports install squirrelmail squirrelmail-locales
  7. Install php-crypt-cbc depends: dpkg -i php-pear_5.2.0-8~bpo.2_all.deb php5-cli_5.2.0-8~bpo.2_i386.deb
  8. Install php-crypt-cbc: dpkg -i php-crypt-cbc_0.4-1_all.deb
  9. apt-get -t sarge-backports install php-fpdf
  10. apt-get install ttf-arphic-ukai amavisd-new awstats bind9 ca-certificates chrootuid clamav clamav-base clamav-daemon clamav-freshclam courier-authdaemon courier-authmysql courier-base courier-ssl gawk libarchive-tar-perl libarchive-zip-perl libasn1-6-heimdal libclamav1 libcompress-zlib-perl libconvert-binhex-perl libconvert-tnef-perl libconvert-uulib-perl libdb4.1 libdigest-sha1-perl libfam0c102 libgmp3 libgssapi1-heimdal libhtml-parser-perl libhtml-tagset-perl libio-multiplex-perl libio-string-perl libio-stringy-perl libio-zlib-perl libkrb-1-kerberos4kth libkrb5-17-heimdal libmailtools-perl libmime-perl libmysqlclient10 libnet-perl libnet-server-perl libnss-mysql libpam-mysql libroken16-kerberos4kth librrd0 librrds-perl libsasl2-modules libtimedate-perl libunix-syslog-perl libxdelta2 libzzip-0-12 mhonarc ncftp php-fpdf php-pear php5-cli php5-curl php5-gd phpmyadmin pure-ftpd-common pure-ftpd-mysql rrdtool sasl2-bin spamassassin spamc sudo ttf-arphic-ukai unzip webalizer xdelta xutils zip
  11. apt-get remove exim4 exim4-base exim4-config exim4-daemon-light mailx mutt
  12. apt-get install postfix postfix-tls postfix-mysql mlmmj courier-pop-ssl courier-pop courier-imap-ssl courier-imap courier-maildrop
  13. dpkg -i dtc-postfix-courier_0.25.2-1_all.deb dtc-toaster_0.25.2-1_all.deb dtc-common_0.25.2-1_all.deb
  14. You need to reset the dtcdaemons password, so that the courier/postfix/etc (anything that still uses the old mysql client libraries) can access the dtc tables. First get the password from /etc/apache2/apache2.conf, then: mysql -uroot -p dtc (and enter the root password for mysql). In the mysql prompt, issue the following command, but, replace newpwd with the password from /etc/apache2/apache2.conf.
  15. SET PASSWORD FOR 'dtcdaemons'@'localhost' = OLD_PASSWORD('newpwd');

This should result in a working CVS dtc install on sarge with backports of php5 and mysql5. If you don't want to build your own versions of each of the debs, you can download from http://tusker.sg/debs/, but note that we might NOT update these against security issues, so it's always better to compile them yourself.


Editing this page means accepting its license.

Page last modified on September 27, 2007, at 05:20 PM EST