This is a very quick-and-dirty how-to for installing MySQL and an SSL/PHP4-enabled Apache webserver on a generic Linux system (I happen to use RedHat 7.1, but I don't think anything here is so unusual it won't work as written on other distributions).

I designed this webpage so that you can hopefully just copy/paste each line/block of commands into your shell session and it will "just work" for you, thus avoiding typing. Text in red is a literal Linux commandline, and should be typed or pasted exactly as written.

Some people have reported problems with the later steps of this procedure if too many lines are cut-and-pasted at once (some directories aren't generated properly, etc). To ensure proper operation, please do the commands one line at a time and wait for the command to complete before executing the next step.

NOTE: If version numbers for some applications are changed when you run this, please use common sense and fix them yourself. Also, if the wget commands for specific files don't work, please go to the appropriate website and download the tarball yourself through whatever mechanism each site provides.

If you find discrepancies in my procedure, or have some other questions, please email me. I will do my best to help you out, but I can't make any promises!

At the time of updating this (27 February 2002) the current versions of all these pieces are:

INITIAL STEPS

Log in as root, change to a "source" directory

cd /usr/local/src

Get tarballs for all applications

wget http://www.php.net/distributions/php-4.1.2.tar.gz
wget http://httpd.apache.org/dist/httpd/apache_1.3.23.tar.gz
wget ftp://ftp.mysql.com/MySQL-3.23/mysql-3.23.49.tar.gz
wget http://www.modssl.org/source/mod_ssl-2.8.7-1.3.23.tar.gz
wget http://www.openssl.org/source/openssl-0.9.6c.tar.gz

Unpack all applications

tar zxvf php-4.1.2.tar.gz
tar zxvf apache_1.3.23.tar.gz
tar zxvf mysql-3.23.49.tar.gz
tar zxvf mod_ssl-2.8.7-1.3.23.tar.gz
tar zxvf openssl-0.9.6c.tar.gz

This should leave you with the following directory structure:

/usr/local/src/php-4.1.2
              /apache_1.3.23
              /mysql-3.23.49
              /openssl-0.9.6c
              /mod_ssl-2.8.7-1.3.23

BUILD/INSTALL MySQL

groupadd mysql
useradd -g mysql mysql

cd /usr/local/src/mysql-3.23.49

./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--disable-maintainer-mode \
--with-mysqld-user=mysql \
--enable-large-files \
--without-comment \
--without-debug \
--without-docs \
--without-bench
make
make install

./scripts/mysql_install_db
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig -v | grep libmysqlclient

This next line adds the MySQL startup command into your rc.local file so that MySQL starts automatically everytime your server comes up.

echo "/usr/local/mysql/bin/safe_mysqld --user=mysql &" >> /etc/rc.d/rc.local

cd /usr/local/mysql/bin
./safe_mysqld --user=mysql &
./mysqladmin version
./mysqladmin -u root password new-password

BUILD/INSTALL OpenSSL

cd /usr/local/src/openssl-0.9.6c
./config --prefix=/usr/local/openssl
make
make test
make install

PATCH APACHE WITH mod_ssl

cd /usr/local/src/mod_ssl-2.8.7-1.3.23
./configure --with-apache=../apache_1.3.23

BUILD/INSTALL APACHE WITH SSL AND DSO SUPPORT

cd /usr/local/src/apache_1.3.23
SSL_BASE=../openssl-0.9.6c ./configure --prefix=/usr/local/apache \
--enable-module=ssl \
--enable-module=so
make
make certificate
make install

BUILD PHP

cd /usr/local/src/php-4.1.2
CFLAGS='-O2 -I/usr/local/src/openssl-0.9.6c' ./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--enable-track-vars \
--with-xml
make
make install
cp php.ini-dist /usr/local/lib/php.ini

Edit Apache config file and start webserver

cd /usr/local/apache/conf
vi httpd.conf

Set up the Apache config file in accordance with Apache instructions (beyond the scope of this HOWTO).

Remove the # at the beginning of the lines which read

#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

Add index.php to the list of valid Directory Index files:

<IfModule mod_dir.c>
����DirectoryIndex index.php index.htm index.html
</IfModule>

Start Apache as an SSL-enabled server:

/usr/local/apache/bin/apachectl startssl