This How-To guides you through the steps to install and configure the most popular and powerful Apache-2.2.8 web server with PHP-5.2.5 and Mysql-5.0.45.

This How-To can be used either on Linux with Kernel version 2.4 and higher or on FreeBSD-6.x systems.

From wikipedia, the definition of a web server is as follows:

A computer program that is responsible for accepting HTTP requests from clients, which are known as web browsers (e.g. Firefox, Internet Explorer), and serving them HTTP responses along with optional data contents, which usually are web pages such as HTML documents and linked objects (images, etc.).

Without Web servers, the Internet would just be as dull as sending and receiving emails.

It is the web server which provides the content and information that we are used to seeing these days. It’s the web server’s job to deliver both static and dynamic contents to end-users via browsers such as Mozilla Firefox and Internet Explorer.

Apache is to web servers what Bind is to DNS servers. Apache is a high performance and scalable web server notable for playing a key role in the initial growth of the World Wide Web. According to the data provided by news.netcraft.com, 50% of all web sites are running on Apache web servers.

In this guide, we will install and configure a simple Apache-2.2.8 web server with PHP-5.2.4 and Mysql-5.0.45.

MySQL is a robust Relational Database Management System (RDBMS) that relies on Structured Query Language (SQL) for processing the data in the database.

MySQL is most commonly used for Web applications and for embedded applications and has become a popular alternative to proprietary database systems such as Oracle and Sybase because of its speed and reliability.

PHP is a reflective programming language originally designed for producing dynamic web pages.PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications.

PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output.

The following guide details the installation and configuration of this 3 powerful components.

Installing Mysql-5.0.45

(1.) Create the necessary mysql user and mysql group

groupadd mysql
useradd -g mysql mysql

(2.) Download Mysql

cd /usr/local/src

wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45.tar.gz/from/http://mirror.trouble-free.net/mysql_mirror/

(3.) Unzip the sources

tar zxvf mysql-5.0.45.tar.gz

(4.) Got to source directory and run configure

cd mysql-5.0.45

./configure -prefix=/usr/local/mysql

(5.) Make and Install

make

make install

(6.) Copy the main my.cnf file and change the necessary permissions and run Mysql

cp support-files/my-medium.cnf /etc/my.cnf

cd /usr/local/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 &
If all goes well, Mysql is now installed and should be running!!

Note: If you face problems such as getting configuration and compilation errors, check your permissions. 95% of all problems can be solved either by installing dependencies and development libraries. Google is your friend as always.

Installing and configuring Apache-2.2.8

(1.) Download Apache

cd /usr/local/src

wget http://veritris.com/mirrors/apache/httpd/httpd-2.2.8.tar.gz

(2.) unzip the sources

tar zxvf httpd-2.2.8.tar.gz

(3.) Configure Apache

cd httpd-2.2.8

./configure

-prefix=/usr/local/httpd \
-enable-cache \
-enable-disk-cache \
-enable-mem-cache \
-enable-proxy \
-enable-proxy-http \
-enable-proxy-ftp \
-enable-proxy-connect \
-enable-so \
-enable-cgi \
-enable-info \
-enable-rewrite \
-enable-speling \
-enable-usertrack \
-enable-deflate \
-enable-mime-magic

(4.) Make and Install

make

make install

That’s it. Apache should now be installed in /usr/local/httpd ! Note: If you face problems such as getting compilation errors, check your permissions. 95% of all problems can be solved either by installing dependencies and development libraries. Google is your friend as always.

Installing and Configuring PHP

(1.) Download PHP

cd /usr/local/src

wget http://www.php.net/get/php-5.2.5.tar.gz/from/us.php.net/mirror

(2.) Unzip the sources

tar zxvf php-5.2.5.tar.gz

(3.) Configure PHP for Apache and Mysql support

./configure

-with-apxs2=/usr/local/httpd/bin/apxs \
-with-mysql=/usr/local/mysql \
-prefix=/usr/local/httpd/php \
-with-config-file-path=/usr/local/httpd/php \
-enable-force-cgi-redirect \
-disable-cgi \
-with-zlib \
-with-gettext \
-with-gdbm

(4.) Make and Install

make

make install

(5.) Configure PHP configuration

cp php.ini-dist /usr/local/lib/php.ini

(6.) Edit your httpd.conf to load the PHP module

vi /usr/local/httpd/conf/httpd.conf

#Added the following in the relevant section

LoadModule php5_module modules/libphp5.so
(7.) Tell Apache to parse certain extensions as PHP and also to parse .phtml and phps extensions

vi /usr/local/httpd/conf/httpd.conf

#Added the following in the relevant sections

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

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

(8.) Start your Apache-2.2.6 server

/usr/local/httpd/bin/apachectl start

Note: If you face problems such as getting configuration and compilation errors, check your permissions. 95% of all problems can be solved either by installing dependencies and development libraries. Google is your friend as always.

Testing PHP installation

(1.) Create the following info.php file in the default htdocs directory

vi /usr/local/httpd/htdocs/info.php

##Copy and paste the following text

<?php
phpinfo();
?>

(2.) Save the file and start your web browser to point to your local web server. If this server is a remote server, simply enter it’s IP address in place of localhost

http://localhost/info.php

You should be able to see detailed information about your PHP installation, Apache environment and PHP extensions loaded, etc.