Site News
Spammer domain block list updated [more]
OSX Killer apps collections updated [more]
 Automatic web page date stamping project [more]
 Basic Perl DBI tutorial [more]

Other Stuff
Farscape returns in 4 hour mini series [more]
Want to take back the internet, [Get Firefox!]
July 05, 2008


DISCLAIMER: All the information contained in this page, or any linked from it, is provided as is, having no warranty or support of any kind, and is used entirely at your own risk.

Basic Apache/PHP/MySQL Installation


This page covers the installation and basic configuration of Apache server, and PHP4 together with support for an existing installation of MySQL. Yes an existing MySQL install, but no need to worry if you don't have one, as its covered in detail in another howto. One last thing to mention before starting is; that all the instructions in this page are for the UNIX/Linux platform only, and are valid only for source distributions only.

What you need

As I said above, this HOWTO only covers the source distributions of Apache and PHP4, so you first need to download these. To make life easer follow these links to get the right files.

Uncompressing

Now you have the files you need, its time to uncompress them, which is done like this. First for the apache server source.

tar xvfz apache_1.3.24.tar.gz

Finally the PHP4 source.

tar xvfz php-4.1.2.tar.gz
TIP: For help with handling compressed files under Linux/Unix/OSX see my HOWTO, which covers most of the common formats in detail.

Starting the build

Now you have everything you need, its time to start the build process. You need to follow the following instructions very carefully, so take it slowly. First you need to configure the apache source for your system, this is done like this.

cd apache_1.3.24
./configure
cd ..

This will take a little while, so when its finished you need to do configure the PHP4 source for your system and make it aware of the apache source and also enable MySQL support, then compile and install it. You do this like this.

cd php-4.1.2
./configure --with-mysql --with-apache=../apache_1.3.24 --enable-track-vars
make
make install

This again is not a quick process, be warned!. Now when this finally finished you need to reconfigure apache so that it is aware of the presence of PHP4, then compile and install it. You do this like this.

cd ../apache_1.3.24
./configure --activate-module=src/modules/php4/libphp4.a
make
make install

This also will take time, so nows a good time for a coffee. Thats it the end of the building, and installation, all thats left is to copy the PHP configuration file, which is done like this.

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

NOTE: The configuration of specific PHP options, is way beyond the scope of this HOWTO, so I refer you to the doco on the php site for more information on this one.

Adding PHP support to Apache

At this point you have installed apache and PHP, but before you can use them you need to update the apache configuration file (/usr/local/apache/conf/httpd.conf) to include support for PHP files, which is done like this.

Open the /usr/local/apache/conf/httpd.conf in your favorite editor, and look for the following line.

### Section 2: 'Main' server configuration

and add the following underneath it.

AddType application/x-httpd-php .php

Thats it for the building, installation and configuration, now its time to test.

Testing

Before starting the server, its always a good idea to make sure that PHP support is installed OK, to do this we ask the apache server to list all the modules compiled in (yes PHP is a module). You do this with the following command.

/usr/local/apache/bin/httpd -l

Which should give you a list like this.

Compiled-in modules:
http_core.c
mod_env.c
mod_log_config.c
mod_mime.c
mod_negotiation.c
mod_status.c
mod_include.c
mod_autoindex.c
mod_dir.c
mod_cgi.c
mod_asis.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_access.c
mod_auth.c
mod_setenvif.c
mod_php4.c
suexec: disabled; invalid wrapper /usr/local/apache/bin/suexec

The line you are looking for, as if you really need to be told! is mod_php4.c, if thats there then the PHP is installed. If its not there, then you need to go back and follow the instructions in the Starting the Build section, as you may have missed something.

If all is well, now you need to start the server, which is done like this.

/usr/local/apache/bin/apachectl start

which should respond like this.

/usr/local/apache/bin/apachectl start: httpd started

Its possible you will get a error that complains about your configuration being broken, if you get this it in this case almost certainly means that when you added the line to /usr/local/apache/conf/httpd.conf you made a typo :-) so go back and check it.

At this point the server should be running OK, so now fire up your favorite browser (on the same machine) and enter

localhost

for the URL. This should produce the apache welcome screen, if you do not get this screen, again you need to go back and check each of the previous steps.

Starting the Server at bootup

You will very likely want to start apache automatically each time you boot your system, while this is again beyond the scope of this document all is not lost, as I have been asked this so often I actually wrote another HOWTO that talks about this in detail. You can find it here.


Links and Related Pages

 
Updated: June 19, 2004 Top