Squirrelmail 1.4.22 on PHP 5.4 and Ensim

Hello all,

As you already read or heared php 5.3 has reached its end-of-life. So basically everyone should upgrade their php version to 5.4 or even 5.5. When I upgraded to 5.4 squirrelmail stopped working (I think it was still version 1.4.9a) and put a lots of error messages into the log. These messages were warnings concerning illegal string offsets.

Even squirrelmail 1.4.22 has problems with php 5.4!? Come on guys, if I'm right php 5.4 is out for about 2 years or so.

So i gave 1.4.23-snapshot a try and it indeed solved the php warnings issue, problem: it is no stable release yet! Although this version solved the biggest problems with php 5.4 it was not compatible with our Ensim box where sites are running in high security mode, btw 1.4.22 wasn't either. After some digging I found out that sqmail 1.4.9a (working on our ensim box) contained an other php_self() function in functions/strings.php than the latest releases.

What was the problem on the Ensim box?

As soon as you tried to log in you got a message like: "you must be logged in" and the link for going back to the login page has /var/www prepended.

Solution:

The solution is quite simple as soon as you find out: take the php_self() from functions/strings.php in sqmail 1.4.9a and replace the new function with the old one in 1.4.22 or 1.4.23

Ensim MySQL connection problems in high security mode

Hello, if you use a site with high security settings, the site's services are chrooted to the virtual file system. Usually the mysql socket file is hardlinked inside the virtual site but in my case this stopped working once and the socket is not linked correctly, resulting in the website not finding the database server.

Now there are several workarounds for that:

  1. Do NOT use localhost to connect but use localhost.localdomain or 127.0.0.1
  2. edit your /etc/init.d/mysqld script and add following line(s) just before the "return $ret" line in the start() section:

    for dir in `ls -d /home/virtual/site*`;
        do rm -f $dir/fst/var/lib/mysql/mysql.sock;
        ln $socketfile $dir/fst/var/lib/mysql/mysql.sock 2> /dev/null;
    done

Apache + mod_deflate

With mod_deflate you can use on-the-fly compression for your content delivered by apache. The content is compressed before it is sent to the browser which decompresses then the received data. Almost all modern browsers support gzip decompression. Although the apache module is called mod_deflate it uses the gzip compression method.

I could reduce the size of a lot of pages by almost 30-40% when delivering. As you can imagine this saves quite some bandwidth and gives you the ability to serve more pages.

So, how to implement this?

first you have to enable mod_deflate in your httpd.conf. Usually this module is already loaded if not uncomment the line or add

LoadModule deflate_module modules/mod_deflate.so

then create a new .conf file in your httpd config directory (usually something like /etc/httpd/conf.d) and add this

# add if module is enabled
<IfModule mod_deflate.c>

    # add content compression for given mime types
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript

    # set default compression level (1-9, higher number = higher compression)
    DeflateCompressionLevel 9

    # make some exceptions for problematic browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # set the deflate logging notice
    DeflateFilterNote Input instream
    DeflateFilterNote Output outstream
    DeflateFilterNote Ratio ratio

    # and set the logging format
    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate

</IfModule>

into a new file, e.g. deflate.conf, save it and restart your apache server. From now on every page loaded will be served with gzip compression.

You can also use gzip compression from .htaccess. Simply add this:

# add if module is enabled
<IfModule mod_deflate.c>

    # add content compression for given mime types
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript

    # make some exceptions for problematic browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

</IfModule>