Compiling PHP with LiteSpeed (with lsapi)

Compiling PHP with litespeed using LiteSpeed 4.10 SAPI.

You must download the latest PHP package and the litespeed sapi package to the /root directory, then run the following commands.
You may wish to change the config settings as needed.

Note: Litespeed was installed in /opt/lsws. You will want to change the prefix accordingly.

cd /root
tar -xjf php-5.3.2.tar.bz2
cd php-5.3.2
cd sapi
tar -xzf /root/php-litespeed-4.10.tgz
cd ..
touch ac*
./buildconf --force

./configure --prefix=/opt/lsws/lsphp5 --with-litespeed --with-config-file-path=/etc/ --with-gd --enable-shmop --enable-track-vars --enable-ftp --enable-sockets --enable-exif --enable-zip --enable-sysvsem --with-zlib --enable-sysvshm --enable-magic-quotes --with-jpeg-dir --with-png-dir --enable-mbstring --enable-embedded-mysqli=shared --with-curl --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config --with-mcrypt
make
make install

/etc/init.d/lsws stop
sleep 5
/bin/cp sapi/litespeed/php /opt/lsws/fcgi-bin/lsphp
/etc/init.d/lsws start

Note: The ‘sleep 5’ statement is not necessary if you do these steps manually. It is added so the copy operation immediately after is successful. Otherwise, litespeed might still be running which will cause the copy operation to fail.

Compiling MySQL with Sphinx

The following commands were used to compile MySQL 5.1.43 with Sphinx 0.9.9. This will install it in /opt.  You may want to change the prefix accordingly.

Download the proper packages and following the following commands.

Note: For some reason, MySQL > 5.1.43 gives a “LT_INIT: command not found” error when compiling. Although it seems like it has something to do with autoconf < 2.2, this was ‘resolved’ by using an older release (5.1.43 instead of 5.1.44) at the time of this writing.

When configuring MySQL, if configure complains about something about no Sphinx, delete the entire MySQL source directory and try again from scratch.

Note: You should already have the following packages installed: libtermcap-devel libgcc-c++ libtool gcc make autoconf g++ gcc-c++

cd /root
tar -xzf mysql-5.1.43.tar.gz
tar -xzf sphinx-0.9.9.tar.gz

You may want to ignore this step if you do not want to compile sphinx with mysql.

cd mysql-5.1.43
cp -R ../sphinx-0.9.9/mysqlse/ storage/sphinx
sh BUILD/autorun.sh

Configure MySQL and compile as usual

./configure --prefix=/opt/mysql --with-unix-socket-path=/opt/mysql/mysql.sock --without-man --enable-shared  --without-debug --enable-assembler --with-ssl --with-plugins=sphinx CFLAGS=-O3 'CXXFLAGS=-O3 -fno-exceptions -felide-constructors -fno-rtti' CXX=gcc
make
make install

Setting up MySQL configuration and the initial database.

/bin/cp /root/my.cnf /etc/my.cnf
/bin/cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
ln -s /etc/init.d/mysql /etc/rc3.d/S40mysql
/bin/cp support-files/my-medium.cnf /etc/my.cnf
/usr/sbin/useradd mysql
cd /opt/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
bin/mysqld_safe --user=mysql &
chown mysql /opt/mysql

Set the lib paths of MySQL so the libmysqlclient.so or whatever else libraries can be found. This is required when attempting to compile anything that requires MySQL (including sphinx).

echo "/opt/mysql/lib/mysql" > /etc/ld.so.conf.d/mysql.conf
ldconfig

Now that MySQL is done, we will compile Sphinx.

cd /root
cd sphinx-0.9.9
./configure --prefix=/opt/sphinx --with-mysql
make
make install

Post install steps:

/bin/cp /root/sphinx.conf /opt/sphinx/etc/sphinx.conf
cp contrib/scripts/searchd /etc/init.d/
chmod 777 /etc/init.d/searchd
ln -s /etc/init.d/searchd /etc/init.d/S55searchd

Setting up BIND on CentOS

The following steps were used to setup BIND using yum on CentOS 5.4. Assume the hostname is titan.steamr.com.
At the time of this writing, the yum repo had BIND 9.3

Step 1: Install the necessary packages:

yum -y install bind bind-libs bind-utils

Step 2: Create a new file /etc/named.conf with the following contents. Change titan.steamr.com for the hostname.
vi /etc/named.conf

options
{
     directory "/var/named"; // the default
};

zone "localhost" {
     type master;
     file "localhost.zone";
};

zone "titan.steamr.com" {
     type master;
     file "titan.steamr.com.zone";
};

Step 3: Create a new file /etc/named/localhost.zone with the following contents:

$TTL    86400
@               IN SOA  @       root (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

                IN NS           @
                IN A            127.0.0.1
                IN AAAA         ::1

Step 4: Create a new file /etc/named/titan.steamr.com.zone with the following contents: (Change titan.steamr.com with your hostname)

$TTL    86400
titan.steamr.com.       14400   IN SOA  tns1.steamr.com root (
                                        20110000        ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

titan.steamr.com.       14400   IN NS           tns1.steamr.com
titan.steamr.com.       14400   IN NS           tns2.steamr.com
titan.steamr.com.       14400   IN A            67.215.230.73
localhost               14400   IN A            127.0.0.1
www                     14400   IN CNAME        titan.steamr.com
ftp                     14400   IN CNAME        titan.steamr.com

Step 5: Start BIND via /etc/init.d/named start

Step 6: Make BIND start on startup mv /etc/rc3.d/K87named S87named

Step 8: To add other DNS entries, append

zone "new.host.com" {
     type master;
     file "new.host.com.zone";
};

and create a new zone file /var/named/new.host.com.zone with something like the contents in step 4.

You will want to reload BIND once you add a new entry by running /etc/init.d/named reload