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

April 2018

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.
  • The PHP source can be downloaded: here
  • The Apache source can be downloaded: here
  • The MySQL source can be downloaded from: here

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

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

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

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

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

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

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
It is important to stop and restart the server:
  • apachectl stop
  • apachectl start

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. Latest update on April 22, 2013 at 07:24 AM 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 (
Setting up a TCP/IP network on Linux
Linux - The fdisk command