IE 6, Apache mod_deflate, blank pages…

I just ran across an interesting bug in IE 6 when a page is loading an external javascript file. If Apache is outputting the external javascript compressed (gzip) IE will do one of the following things:

  1. Return a blank page
  2. Try loading the page forever

Prior to finding this bug, our apache settings for mod_deflate looked like…

AddOutputFilterByType DEFLATE text/html text/css text/xml text/plain application/x-javascript

Now it looks like…

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.[0678] no-gzip
BrowserMatch \bMSIE\s7Â !no-gzip !gzip-only-text/html

Making these changes seemed to have fixed the issue. Now when a page is loaded in IE6, any external javascript file will not be gzipped and their page load will be slower. I suppose that is punishment for not upgrading to IE7 or getting Firefox.

JavaScript – Safari Bug?

On PaperBackSwap and SwapaCD we have some tool-tip rollovers that display a definition of what we define as keywords. (This can be seen in action on http://www.paperbackswap.com/help/hdtw.php. The word “credit” has been highlighted.) It came to our attention the other day that Safari was display anything replaced by JavaScript as $& which was suppose to be the text or “keyword” it found. We have a separate JavaScript file that gets loaded into the page that has the keywords we have definitions for. Well the $& worked for in both IE 6 and 7, Firefox 1.5 and 2 and Opera but not Safari. Simply changing the $& to $1 since I only needed the first thing it found solved the problem. So now when the user clicks one of the links with dashes under it they get the definition of that keyword loaded up from the server with an AJAX call. Yipee now all the browsers are working again…..

PHP frontend to Subversion (SVN)

dev_file_control.jpgSo over the last week I have been working on and off with a PHP frontend to SVN. The frontend needed to be designed in such a way that each developer could access their working copies and make the full range of actions against them. I decided to also use an AJAX setup so that pages would be quickly loaded and updated by a single toggle of a folder. The first issue that I had to deal with was when a SVN command was issues it needed to be issued as the owner of the code so that SVN could track edits correctly. After googling around for a bit I quickly realized that there was not a viable Apache MPM that would serve virtual hosts under different users and groups. Then the light bulb flipped on, setup a proxy and redirect requests to developer.dev.domain.com to its own instance of apache running as the user and group ‘developer’. This would ensure that all SVN commands would run as ‘developer’ when executed. I then moved onto setting up the interface. The features that are working at this time are:

  1. create working copy from repository (svn checkout)
  2. delete working copy
  3. svn add
  4. svn blame
  5. svn commit
  6. svn copy
  7. svn delete
  8. svn diff
  9. svn move
  10. svn propset
  11. search files (via a grep/find combination, omitting .svn folders)
  12. svn log
  13. svn rename
  14. svn status
  15. update local working copy
  16. update stage environment
  17. publish stage environment

A few things that I learned while working with doing the SVN commands was that when executing a command via the php function exec() I need to add the flag –config-dir=$USER_HOME_DIR/.subversion (or where ever the users .subversion folder is located). Also if a command does not seem to be executing correctly you can add “2>&1″ without quotations to the command being run and it will return any error messages through the $ouput variable for exec();

Our new hardware setup

Photo of the new serversAfter our latest purchase with Dell, all I can say is that Micheal Dell will be able to buy a nice new watch. Currently in the office we have a stack of new machines that are getting close to being fully configured ready for the move to the data center. If anyone is looking for a collocation facility in the Atlanta, Georgia area I would highly recommend Quality Tech. Quality Tech is the former E-Delta Com and have a really cool data center in Suwanee, which will be the home to our new boxes. We ended up with the following combination of servers:

  • 7 – Poweredge 860
    • 2 – LVS
    • 2 – WWW
    • 2 – NFS
      • Director, Slave configuration using hearbeat
      • Replicate Data in real time with DRBD to allow for hot failover
      • Will also serve web traffic at half of the ratio compared to the WWW boxes
    • 1 – DEV
  • 3 – Poweredge 2950
    • 2 – DB (MySQL dual master configuration)
    • 1 – Backup Master with alot of storage space
  • 1 – Poweredge SC430
    • data set compilation, mostly sits idle
  • 1 – Clone Machine
    • Old Backup server, will become backup slave

Install of Apache 2.2.3, MySQL 5.0.18 and PHP 5.2.0

After getting our new servers delivered I came to the conclusion very quickly that I would like a way to easily get the same configurations on every box without having to spend the rest of my life doing so. Each box needed to have Apache, MySQL and PHP installed and configured. I decided to write a bash script to do this for me. In the end I am very happy with the way that the script works. It leaves very little work to be done once the script is done running. In the end I have two scripts, one is for a 32bit machine and one is for 64bit machines. Below is the 64bit script. The install will compile PHP with all of the supported modules that we need. The only thing that needs to be done with PHP is the setting the correct config options in the php.ini, this includes putting in APC cache extension.

#!/bin/sh

# Abort on any errors
set -e

# Where do you want all this stuff built?
SRCDIR=/home/support/software/source

# Unpack our large file that contains all needed packages that are not going to be obtained from yum
#rm -Rf ${SRCDIR}
#gzip -d nbs_core_install.gz
#cd nbs_core_install/
#cp -R * ${SRCDIR}/

# Install gcc
yum -y install gcc

# Install cc
yum -y install cc

# Install libtool
yum -y install libtool

# Extract OpenSSH and install openssh and the sshd in the init.d
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssh-4.5p1.tar.gz
cd ${SRCDIR}/openssh-4.5p1
./configure
make
make install
cp -f ${SRCDIR}/sshd.init.d /etc/rc.d/init.d/sshd
chmod 755 /etc/rc.d/init.d/sshd
rm -f /etc/rc.d/rc3.d/S70sshd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/sshd S70sshd
rm -Rf ${SRCDIR}/openssh-4.5p1

# Install libjpeg-devel
yum -y install libjpeg-devel

# Install jpeg.v6b
cd ${SRCDIR}
tar xzf ${SRCDIR}/jpegsrc.v6b.tar.gz
cd ${SRCDIR}/jpeg-6b
cp /usr/share/libtool/config.guess ./
cp /usr/share/libtool/config.sub ./
./configure –enable-shared
make libdir=/usr/lib64
install -d /usr/local/man/man1
make libdir=/usr/lib64 install
rm -Rf ${SRCDIR}/jpeg-6b

# Install libtiff & libtiff-devel
yum -y install libtiff libtiff-devel

# Install Ghostscript (needed for ImageMagick)
yum -y install ghostscript

# Install ImageMagick
yum -y install ImageMagick

# Install libxml2
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxml2-2.6.27.tar.gz
cd ${SRCDIR}/libxml2-2.6.27
./configure –enable-shared
make
make install
make tests
rm -Rf ${SRCDIR}/libxml2-2.6.27

# Install libxslt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxslt-1.1.19.tar.gz
cd ${SRCDIR}/libxslt-1.1.19
./configure –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/libxslt-1.1.19

# Install zlib
cd ${SRCDIR}
tar xzf ${SRCDIR}/zlib-1.2.3.tar.gz
cd ${SRCDIR}/zlib-1.2.3
./configure –shared –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/zlib-1.2.3

# Install libmcrypt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libmcrypt-2.5.7.tar.gz
cd ${SRCDIR}/libmcrypt-2.5.7
./configure –disable-posix-threads –prefix=/usr
make
make install

# Install libmcrypt lltdl
cd ${SRCDIR}/libmcrypt-2.5.7/libltdl
./configure –prefix=/usr –enable-ltdl-install
make
make install
rm -Rf ${SRCDIR}/libmcrypt-2.5.7

# Install mhash
cd ${SRCDIR}
tar xzf ${SRCDIR}/mhash-0.9.7.1.tar.gz
cd ${SRCDIR}/mhash-0.9.7.1
./configure –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/mhash-0.9.7.1

# Install Freetype
cd ${SRCDIR}
tar xzf ${SRCDIR}/freetype-2.2.1.tar.gz
cd ${SRCDIR}/freetype-2.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/freetype-2.2.1

# Install libidn
cd ${SRCDIR}
tar xzf ${SRCDIR}/libidn-0.6.9.tar.gz
cd ${SRCDIR}/libidn-0.6.9
./configure –with-iconv-prefix=/usr –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/libidn-0.6.9

# Install OpenSSL
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssl-0.9.8d.tar.gz
cd ${SRCDIR}/openssl-0.9.8d
./config
make
make test
make install
rm -Rf ${SRCDIR}/openssl-0.9.8d

# Install cURL
cd ${SRCDIR}
tar xzf ${SRCDIR}/curl-7.15.0.tar.gz
cd ${SRCDIR}/curl-7.15.0
./configure –enable-ipv6 –enable-cookies –enable-crypto-auth –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/curl-7.15.0

# Install c-client (IMAP)
cd ${SRCDIR}
tar xzf ${SRCDIR}/imap-2004g.tar.Z
cd ${SRCDIR}/imap-2004g
make lrh
cp c-client/c-client.a /usr/lib/libc-client.a
cp c-client/*.h /usr/include
rm -Rf ${SRCDIR}/imap-2004g

# Install Apache
cd ${SRCDIR}
tar xzf ${SRCDIR}/httpd-2.2.3.tar.gz
cd ${SRCDIR}/httpd-2.2.3
./configure –enable-rewrite –enable-ssl –enable-deflate –enable-so –enable-proxy –prefix=/usr/local/apache2
make
make install
rm -Rf ${SRCDIR}/httpd-2.2.3

# Install httpd init.d file
cd ${SRCDIR}
rm -f /etc/rc.d/init.d/httpd
cp httpd.init.d /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
rm -f /etc/rc.d/rc3.d/K*httpd
rm -f /etc/rc.d/rc3.d/S*httpd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/httpd F15sshd

# Install libpng
cd ${SRCDIR}
tar xzf ${SRCDIR}/libpng-1.2.15.tar.gz
cd ${SRCDIR}/libpng-1.2.15
./configure
make
make install
rm -Rf ${SRCDIR}/libpng-1.2.15

# Install MySQL
yum -y install perl-DBI
cd ${SRCDIR}
rpm -i MySQL-server-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-client-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-devel-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-shared-standard-5.0.18-0.rhel4.x86_64.rpm
rpm -i MySQL-standard-debuginfo-5.0.18-0.rhel4.x86_64.rpm
ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a

# Install Flex
yum -y install flex

# Install libdv
yum -y install libdv

# Install re2c needed for php pfro compile
cd ${SRCDIR}
tar zxf ${SRCDIR}/re2c-0.11.0.tar.gz
cd ${SRCDIR}/re2c-0.11.0
./configure
make
make install

# Install PHP
cd ${SRCDIR}
tar xzf ${SRCDIR}/php-5.2.0.tar.gz
cd ${SRCDIR}/php-5.2.0
./configure ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib64′ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–with-mcrypt=/usr’ ‘–with-config-file-path=/etc’ ‘–with-bz2′ ‘–with-curl’ ‘–with-curl-ssl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-gd’ ‘–with-ttf’ ‘–with-gdbm’ ‘–with-gettext’ ‘–with-ncurses’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg’ ‘–with-openssl’ ‘–with-png’ ‘–with-regex=system’ ‘–with-xsl=/usr’ ‘–with-expat-dir=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–with-kerberos=/usr/kerberos’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–without-oci8′ ‘–enable-inline-optimization’ ‘–enable-gd-native-ttf’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-sockets’ ‘–enable-trans-sid’ ‘–enable-memory-limit’ ‘–disable-rpath’ ‘–disable-debug’ ‘–with-mysql=/usr/local/mysql’ ‘–with-mysqli=/usr/bin/mysql_config’
make
make install
cp php.ini-dist /etc/php.ini
rm -Rf ${SRCDIR}/php-5.2.0

# Install Memcache PHP Extension
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcache-2.1.0.tgz
cd ${SRCDIR}/memcache-2.1.0
phpize
./configure
make
mkdir /usr/local/phpextensions/
cp ${SRCDIR}/memcache-2.1.0/modules/memcache.so /usr/local/phpextensions/
rm -Rf ${SRCDIR}/memcache-2.1.0

# Install APC (php cache)
cd ${SRCDIR}
tar xzf ${SRCDIR}/APC-3.0.12p2.tgz
cd ${SRCDIR}/APC-3.0.12p2
phpize
./configure –enable-apc-mmap=yes –with-apxs2=/usr/local/apache2/bin/apxs
make
cd ${SRCDIR}/APC-3.0.12p2/modules/
cp apc.so /usr/local/phpextensions

# Install libevent-devel
yum -y install libevent-devel

# Install Memcache Daemon
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcached-1.2.1.tar.gz
cd ${SRCDIR}/memcached-1.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/memcached-1.2.1

# Install BRUTIS
cd ${SRCDIR}
cp monitor.php /home/support/
chmod 700 /home/support/monitor.php
cp ${SRCDIR}/crontab_root /var/spool/cron/root

# Install perl-Net-SSLeay
yum -y install perl-Net-SSLeay

# Install Webmin
cd ${SRCDIR}
rpm -U webmin-1.310-1.noarch.rpm

echo
echo
echo ———- INSTALL COMPLETE! ———-
echo
echo

And here is the 32bit script.

#!/bin/sh

# Abort on any errors
set -e

# Where do you want all this stuff built?
SRCDIR=/home/support/software/source

# Install gcc
yum -y install gcc

# Install libtool
yum -y install libtool

# Extract OpenSSH and install openssh and the sshd in the init.d
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssh-4.5p1.tar.gz
cd ${SRCDIR}/openssh-4.5p1
./configure
make
make install
cp -f ${SRCDIR}/sshd.init.d /etc/rc.d/init.d/sshd
chmod 755 /etc/rc.d/init.d/sshd
rm -f /etc/rc.d/rc3.d/S70sshd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/sshd S70sshd
rm -Rf ${SRCDIR}/openssh-4.5p1

# Install libjpeg-devel
yum -y install libjpeg-devel

# Install jpeg.v6b
cd ${SRCDIR}
tar xzf ${SRCDIR}/jpegsrc.v6b.tar.gz
cd ${SRCDIR}/jpeg-6b
cp /usr/share/libtool/config.guess ./
cp /usr/share/libtool/config.sub ./
./configure –enable-shared
make
install -d /usr/local/man/man1
make install
rm -Rf ${SRCDIR}/jpeg-6b

# Install libtiff & libtiff-devel
yum -y install libtiff libtiff-devel

# Install Ghostscript (needed for ImageMagick)
yum -y install ghostscript

# Install ImageMagick
yum -y install ImageMagick

# Install libxml2
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxml2-2.6.27.tar.gz
cd ${SRCDIR}/libxml2-2.6.27
./configure –enable-shared
make
make install
make tests
rm -Rf ${SRCDIR}/libxml2-2.6.27

# Install libxslt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libxslt-1.1.19.tar.gz
cd ${SRCDIR}/libxslt-1.1.19
./configure –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/libxslt-1.1.19

# Install libmcrypt
cd ${SRCDIR}
tar xzf ${SRCDIR}/libmcrypt-2.5.7.tar.gz
cd ${SRCDIR}/libmcrypt-2.5.7
./configure –prefix=/usr
make
make install

# Install Freetype
cd ${SRCDIR}
tar xzf ${SRCDIR}/freetype-2.2.1.tar.gz
cd ${SRCDIR}/freetype-2.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/freetype-2.2.1

# Install OpenSSL
cd ${SRCDIR}
tar xzf ${SRCDIR}/openssl-0.9.8d.tar.gz
cd ${SRCDIR}/openssl-0.9.8d
./config
make
make test
make install
rm -Rf ${SRCDIR}/openssl-0.9.8d

# Install cURL
cd ${SRCDIR}
tar xzf ${SRCDIR}/curl-7.15.0.tar.gz
cd ${SRCDIR}/curl-7.15.0
./configure –enable-ipv6 –enable-cookies –enable-crypto-auth –prefix=/usr
make
make install
rm -Rf ${SRCDIR}/curl-7.15.0

# Install c-client (IMAP)
cd ${SRCDIR}
tar xzf ${SRCDIR}/imap-2004g.tar.Z
cd ${SRCDIR}/imap-2004g
make lrh
cp c-client/c-client.a /usr/lib/libc-client.a
cp c-client/*.h /usr/include
rm -Rf ${SRCDIR}/imap-2004g

# Install Apache
cd ${SRCDIR}
tar xzf ${SRCDIR}/httpd-2.2.3.tar.gz
cd ${SRCDIR}/httpd-2.2.3
./configure –enable-rewrite –enable-ssl –enable-deflate –enable-so –enable-proxy –prefix=/usr/local/apache2
make
make install
rm -Rf ${SRCDIR}/httpd-2.2.3

# Install httpd init.d file
cd ${SRCDIR}
rm -f /etc/rc.d/init.d/httpd
cp httpd.init.d /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
rm -f /etc/rc.d/rc3.d/K*httpd
rm -f /etc/rc.d/rc3.d/S*httpd
cd /etc/rc.d/rc3.d && ln -s /etc/rc.d/init.d/httpd F15sshd

# Install libpng
cd ${SRCDIR}
tar xzf ${SRCDIR}/libpng-1.2.15.tar.gz
cd ${SRCDIR}/libpng-1.2.15
./configure
make
make install
rm -Rf ${SRCDIR}/libpng-1.2.15

# Install MySQL
yum -y install perl-DBI
cd ${SRCDIR}
rpm -i MySQL-server-standard-5.0.18-0.rhel3.i386.rpm
rpm -i MySQL-client-standard-5.0.18-0.rhel3.i386.rpm
rpm -i MySQL-devel-standard-5.0.18-0.rhel3.i386.rpm
rpm -i MySQL-shared-standard-5.0.18-0.rhel3.i386.rpm

# Install Flex
yum -y install flex

# Install libdv
yum -y install libdv

# Install PHP
cd ${SRCDIR}
tar xzf ${SRCDIR}/php-5.2.0.tar.gz
cd ${SRCDIR}/php-5.2.0
./configure ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib64′ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–with-mcrypt=/usr’ ‘–with-config-file-path=/etc’ ‘–with-bz2′ ‘–with-curl’ ‘–with-curl-ssl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–with-gd’ ‘–with-ttf’ ‘–with-gdbm’ ‘–with-gettext’ ‘–with-ncurses’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg’ ‘–with-openssl’ ‘–with-png’ ‘–with-regex=system’ ‘–with-xsl=/usr’ ‘–with-expat-dir=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–with-kerberos=/usr/kerberos’ ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–without-oci8′ ‘–enable-inline-optimization’ ‘–enable-gd-native-ttf’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-sockets’ ‘–enable-trans-sid’ ‘–enable-memory-limit’ ‘–disable-rpath’ ‘–disable-debug’ ‘–with-mysql=/usr/local/mysql’ ‘–with-mysqli=/usr/bin/mysql_config’
make
make install
cp php.ini-dist /etc/php.ini
rm -Rf ${SRCDIR}/php-5.2.0

# Install Memcache PHP Extension
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcache-2.1.0.tgz
cd ${SRCDIR}/memcache-2.1.0
phpize
./configure
make
mkdir /usr/local/phpextensions/
cp ${SRCDIR}/memcache-2.1.0/modules/memcache.so /usr/local/phpextensions/
rm -Rf ${SRCDIR}/memcache-2.1.0

# Install APC (php cache)
cd ${SRCDIR}
tar xzf ${SRCDIR}/APC-3.0.12p2.tgz
cd ${SRCDIR}/APC-3.0.12p2
phpize
./configure –enable-apc-mmap=yes –with-apxs2=/usr/local/apache2/bin/apxs
make
cd ${SRCDIR}/APC-3.0.12p2/modules/
cp apc.so /usr/local/phpextensions

# Install libevent-devel
yum -y install libevent-devel

# Install Memcache Daemon
cd ${SRCDIR}
tar xzf ${SRCDIR}/memcached-1.2.1.tar.gz
cd ${SRCDIR}/memcached-1.2.1
./configure
make
make install
rm -Rf ${SRCDIR}/memcached-1.2.1

# Install BRUTIS
cd ${SRCDIR}
cp monitor.php /home/support/
chmod 700 /home/support/monitor.php
cp ${SRCDIR}/crontab_root /var/spool/cron/root

# Install perl-Net-SSLeay
yum -y install perl-Net-SSLeay

# Install Webmin
cd ${SRCDIR}
rpm -U webmin-1.310-1.noarch.rpm

echo
echo
echo ———- INSTALL COMPLETE! ———-
echo
echo