Installing a web server (Apache, PHP and MySQL) under Linux

March 2017


In this article your shall learn how to install the Apache web server on a UNIX-based system (typically a Linux distribution such as RedHat, Mandrake or any other). The following procedure includes the installation of the PHP interpreter, a programming language for creating dynamic pages as well as the MySQL database, a database management system running on Linux.

Download the source

  • The PHP source can be downloaded: here
  • The Apache source can be downloaded: here
  • The MySQL source can be downloaded from: here

Installing Apache and PHP

Unpack the archive:

tar zxvf apache_1.3.x.tar.gz   
tar zxvf php-3.0.x.tar

Configuring Apache

cd apache_1.3.x   
./configure --prefix=/www

Configure PHP

cd ../php-3.0.x   
./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars

Compiling PHP

To install PHP in another directory, you must use the --with-config-file-path=/path configuration option:
make install

Installing Apache

cd ../apache_1.3.x   
./configure --prefix=/www --activate-module=src/modules/php3/libphp3.a   
make install

Edit the configuration file of PHP

cd ../php-3.0.x   
cp php3.ini-dist /usr/local/lib/php3.ini

You can now edit the /usr/local/lib/php3.ini configuration file

Change extension associated with PHP scripts. For consistency, it is common to choose the .php3 extension:

Edit the configuration file of the Apache server (usually httpd.conf or srm.conf and add the following line):
AddType application/x-httpd-php3 .php3

Re-start the Apache server

It is important to stop and restart the server:
  • apachectl stop
  • apachectl start

First launch

To check if the installation was successful, simply create a small file in the document root of the web server ( DocumentRoot in httpd.conf). Name this file as test.php3 file and put the following code in this file:




echo "PHP Works!";



  • Open a browser on your machine and enter the following URL:
  • http://localhost/test.php3
  • Where localhost: refers to the machine on which you are ...
  • The phrase "PHP works!" should appears in your browser!

Orginal document published by Rémy Pouchain on


Published by jak58.
This document, titled "Installing a web server (Apache, PHP and MySQL) under Linux," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (