Linux/UNIX Installation

Whenever you compile applications from a source archive, the build process depends on your system having the correct development tools and libraries in place. Although the following instructions were tested on Red Hat Linux and SuSE Linux systems, the steps are the same for a default installation of all other Linux or commercial UNIX distributions.

Should you encounter unexpected error messages during compilation, contact your systems administrator or refer to the documentation for your particular operating system.

Begin as the superuser (either log in as root or su from a regular system user) and mount the CD-ROM under /mnt on your filesystem:

# mount /dev/cdrom /mnt t iso9660

The following sections detail the installation processes for MySQL, Apache, and PHP, from the CD-ROM.

Installing MySQL

Before installing MySQL we need to create a user on the system that will run the MySQL server:

# groupadd mysql
# useradd g mysql mysql

We will put the source distribution in the /usr/local/ directory, so let’s extract the MySQL archive from the CD-ROM:

# cd /usr/local/
# gunzip < /mnt/MySQL/Linux/tarballs/source/mysql-5.0.20.tar.gz | tar xf

This creates a directory called mysql-5.0.20 containing the binary distribution. Create a link with a shorter name:

# ln -s mysql-VERSION-PLATFORM mysql

Change directories to the new directory:

# cd mysql

Issue the following series of commands to finish the installation and start your MySQL server:

# scripts/mysql_install_db --user=mysql
# chown -R root  .
# chown -R mysql mysql_data
# chgrp -R mysql .
# bin/mysqld_safe --user=mysql &

The last command in the list, the MySQL startup command, can be added to your system startup script to ensure the MySQL server is always started following a reboot. For instance, on Red Hat Linux add the command to /etc/rc.d/rc.local.

If you want to test that MySQL is running, use the mysqladmin status command to get a short status message from a running server:

# /usr/local/mysql/bin/mysqladmin status
Uptime: 8826  Threads: 1  Questions: 10  Slow queries: 0  Opens: 8
Flush tables: 1  Open tables: 2  Queries per second avg: 0.000

Installing Apache

Extract the Apache source code from the CD-ROM to /usr/local/src and change to that directory:

# cd /usr/local/src
# gunzip < /mnt/Apache/Linux/source/httpd-2.0.58.tar.gz | tar xf 
# cd httpd-2.0.58

We want to install Apache under /usr/local/apache2 and configure the web server to allow Dynamic Shared Objects (DSO), so that we don’t need to rebuild Apache to add in PHP support. The configure command therefore looks like this:

# ./configure --prefix=/usr/local/apache2 --enable-module=so

Other compile-time options can be specified at this time, but for the purposes of this book the example given will be sufficient.

Compile and install Apache, and then start the web server with the apachectl command:

# make
# make install
# /usr/local/apache2/bin/apachectl start

To test that the web server is running, open a web browser and enter the name or IP address of your server as the location. If you have not specified a host name in the Apache configuration, you can use localhost or to access your server. The default page for a new installation tells you that everything has worked

Installing PHP

Extract the PHP source code from the CD-ROM to /usr/local/src and change to that directory:

# cd /usr/local/src
# gunzip < /mnt/PHP/Linux/source/php-5.1.4.tar.gz | tar xf 
# cd php-5.1.4

We need PHP to include MySQL support and to link into Apache using DSO using the apxs utility. We’ll also use the prefix /usr/local/php for the essential PHP files:

# ./configure  --prefix=/usr/local/php \
--with-mysqli=/usr/local/mysql/bin/mysql_config \

Then use the make and make install commands to compile and install PHP:

# make
# make install

The apxs utility does most of the hard work here. Once the PHP module is built, it should be copied to the correct location on the filesystem and the Apache configuration should be automatically modified to load the module at start time.

We need to make one more change to the Apache configuration file to instruct the web server to process any .php file as a PHP script. We’ll also activate PHP for files ending in .html. Edit /usr/local/apache2/conf/httpd.conf and add the following line:

AddType application/x-httpd-php .php  .html

Restart Apache with the apachectl command to make sure that the changes to the configuration file are acted upon:

# /usr/local/apache2/bin/apachectl restart

To test that PHP is now a part of your web server, create a simple script as /usr/local/apache2/htdocs/phpinfo.php that looks like this:


In your web browser, visit http://localhost/phpinfo.php on your new server and you should see a page giving a lot of information on the PHP configuration.