Logo by Bart Peperkamp [EL3D]
 
We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare.
Now, thanks to the Internet, we know this is not true. - Robert Wilensky, 1996
  Login
  Nieuws
  Tutorials
  Downloads
  Webhosting
  Zoeken
  Info
  MyMDB
  Link Collective
Website test

Installing "the terrible two"

The easy way of getting apache and php to run

By Osiris Administrator

In this tutorial we'll go in depth at how we can accomplish a standard install using the most popular webcombo known, apache and php.
This tutorial is based on the latest version of both at the time of writing, which are Apache 2.x and PHP 4.x. Note that some options may differ from the ones in this tutorial, when in doubt i suggest trying the manual or latest faq and look whether they made a namechange for some option. When even further confused i suggest trying to obtain the versions i am using here.

Getting down and dirty

Well let's start, shall we?
First of all, obtain the newest versions. For Apache they can be found at: http://nagoya.apache.org/dist/httpd/binaries/win32/. You will be wanting the "win32-x86-nossl" version.
As for php, look at: http://www.php.net/downloads.php You will be wanting the "win32 zip package", remember to use the zip (about 6Mb), it's more complete.

For those interested in learning anything about php, the documentation downloadable at php.net is one of the finest manuals ever. And a little background info never killed anyone.. Fetch it here unless you're not interested in actually programming anything with php: http://www.php.net/download-docs.php
Now, with everything on stand by, let's start..

Step 1 - Installing Apache 2

Just find the installer and start it up. You'll now be greeted by the installation menu, just keep "nexting" until the "server information" menu comes up.

Network Domain:
Just fill in the name the computer uses to identify itself on your network (ie: Osiris, Muse of whatever)

Server Name:
Just fill in the computer's ip-address like xxx.xxx.xxx.xxx.

Administrator Email Address:
May be any correctly spelled email address, a right one does provide you with contact info for lost visitors.

Install Apache Http server 2.0 programs and shortcuts for:
Always select "for all users, on port 80, as a service". Startup problems otherwise.

Select Next.

Now select typical, what doesn't get installed are the headers and modules for compiling your own apache, not particulary interesting.

Select Next.

Select a good destination folder, for the directory purists (like myself), remember that within this folder the folder "apache2" is placed and in there finally the files are placed. So "C:\" or "D:\" will do fine..

Again select next and install. Seclect "Finish" to exit the installer, by now an icon should have appeared in your system tray indicating the server is ready and running.

Try it by opening a browser and going to: "localhost" or your network name.

Step 2 - Installing PHP 4

Now this one is easy, just unzip the download towards the drive of your choice. For easier reference rename the directory from "php-4.2.3-Win32" to "php4".

Step 3 - Configure Apache

Now it's time to teach Apache the existence of php. In order to do this we'll need the httpd.conf in the directory "conf". It's a good idea to first make a backup of this file.
What to change (in order of appearance)

Change the following line:
#LoadModule rewrite_module modules/mod_rewrite.so
into
LoadModule rewrite_module modules/mod_rewrite.so
This will activate url rewriting which we'll need for the .htaccess security.

Change the following line:
DocumentRoot "D:/Apache2/htdocs" (or similar, may be another location)
into
DocumentRoot "D:/Website" (or similar, may be another location)
This points to the location of your website.

Change the following lines:

Options FollowSymLinks
AllowOverride None

into

Options FollowSymLinks
AllowOverride All

Which tells apache to give security changing rights to the .htaccess file.

Change the following line:
(or similar, may be another location)
into
(or similar, may be another location)
This should be changed to whatever you set DocumentRoot to.

Change the following line:
AllowOverride None
into
AllowOverride All
Which tells apache to give security changing rights to the .htaccess file.

Change the following line:
DirectoryIndex index.html index.html.var
into
DirectoryIndex index.html index.php
Which tells apache which files are accepted as index pages, add more if you like.

Add the following line:
ScriptAlias /cgi-bin/ "D:/Apache2/cgi-bin/"
into
ScriptAlias /cgi-bin/ "D:/Apache2/cgi-bin/"
ScriptAlias /php/ "D:/php4/" (or similar, may be another location)
Where is php? Read carefully, i am actually adding a line..

Change the following lines:
AddType application/x-tar .tgz
AddType image/x-icon .ico
into
AddType application/x-tar .tgz
AddType image/x-icon .ico
AddType application/x-httpd-php .php
What to do with a .php? Read carefully, i am actually adding a line..

Somewhere right below that, add this line:
Action application/x-httpd-php "/php/php.exe"
Where do i find the php.exe?

That's it!
Now remember, save the .conf file and restart apache by using the system bar icon.
Oh, and create the directory you appointed as the website's folder (if it doesn't allready exist), because if it doesn't exist the apache service will not start.. ;)

Step 4 - Configure PHP

Now that's done, it's time to teach php some stuff. ;) First give php an ini to work with, it doesn't install one out-of-the-box..
Copy the "[PHP INSTALL DIR]\php.ini-dist" to "c:\windows\php.ini"
Now open it in notepad and here we go:

Change the following line:
register_globals = Off
into
register_globals = On
Makes url variables accessable to the page, not the most secure way, but good for novices..

Change the following line:
extension_dir = ./
into
extension_dir = d:/php/extensions/ (or similar, may be another location)
Tells php where to find it's extensions, standard stuff..

Change the following line:
upload_max_filesize = 2M
into
upload_max_filesize = 5M (or whatever you think is reasonable)
Tells php how big files may be that are uploaded via forms (ie pictures etc.).

Change the following line:
session.save_path = /tmp
into
session.save_path = d:/php4/sessions (or similar, may be another location)
Where the user's sessioninformation is stored, create this directory!

Done!
Your website's program structure is now ready, unpack or create your website in it's appointed directory and go!