mitchenall.com - The Database & Web Enabling Company  
Services Products Resources Contacts
* Consultancy
* Training
* Bespoke Development
* Web Development and Hosting
* 4D Freeware
-> Articles & Tutorials
* External Links
* Site Index
* Recommended Reading
* @mitchenall.com
* Feedback

> Home > Resources > Articles & Tutorials > Non-Programming Articles

Setting up Apache, PHP3 and mySQL on Windows 98 in 15 Minutes

This doesn't include the time it takes to find and download the software, unless you've got an extremely fast connection and work fast, so if you haven't got the software yet, here's where you get the various pieces. There's only 3 items to download, but it's worthwhile getting a couple of extras for mySQL to make life easier.

Apache can be downloaded from http://www.apache.com/. It's free software, so there's no need to get your credit card out.

mySQL for the Win32 platform is shareware, but you can evaluate the product for 30 days for free. Still, it's well worth shelling out the $200 for it if you plan to continue using it as it's a great product and $200 is very little money these days for the data you're getting for your money. The latest version of mySQL can always be downloaded from the mySQL website at http://www.mysql.com/.

The PHP Wesite can be found at http://www.php.net/. You can download the latest version for Win32 from there. This is freeware. Don't you just love all this shareware and freeware stuff.

All the binaries are downloaded, now start the installation

Install each piece of software using the installer which comes with them. Just let the installer put the items in the default locations. That way, you know they should all work properly. Recent installations carried out at mitchenall.com ended up with the various programmes being installed into the following directories:

Application Directory installed into
Apache 1.3.6 C:\Program Files\Apache Group\Apache\
mySQL 3.21 C:\mysql\
PHP 3.0.11 C:\php3\

Now that you have the 3 components installed you just need to tell them how to talk to each other. In the case of mySQL, you don't need to do anything. PHP has native support for mySQL, just you just need to make sure that PHP is set up to talk to it. All you need to with mySQL is to run it, which in the case of mySQL means runing a small application called "mysqld.exe".

This file is located in "C:\mysql\bin\", so you could simply select "Run..." from your start menu and enter "C:\mysql\bin\mysqld".

"mysqld.exe" just starts up a background process and then immediately quits, so don't worry if it looks like nothing happened. mySQL should definitely be runing at this point. To quit mySQL, assuming you've not done anything with it and haven't set any new passwords for it, run "c:\mysql\bin\mysqladmin -u root -shutdown".

Configuring Apache for PHP3

Apache needs to be told about PHP3 and which files to process using PHP3. In order to tell Apache these things, we need to modify one of Apache's config files. These are text files which contain all the operating parameters for Apache and can be found in the "conf" directory in the Apache directory. Assuming that when you installed Apache, everything went into the same place as it did for us, the full path to this directory should be "C:\Program Files\Apache Group\Apache\conf\" and the file we're after is "httpd.conf", i.e. "C:\Program Files\Apache Group\Apache\conf\httpd.conf".

"httpd.conf" is a standard ASCII text file and can be opened with a text editor such as Notepad. There are a couple of things which need to be changed/added to this file. First, we need to tell Apache about PHP, what type of files it needs to process with PHP, and where PHP is. To do this, add the following text at the end of the "httpd.conf" file.

ScriptAlias /php3/ "c:/php3/"
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .phtml
Action application/x-httpd-php3 "/php3/php.exe"

The first line tells Apache to create an alias to the folder in which the PHP3 application can be found (in our case "C:\php3\"). Note that the "slashes" go forward and not backward as they would normally on Windows.

The second and third lines define the standard PHP filename extensions to Apache and tell Apache what action to carry out when one of these filename extensions is found.

The fourth line tells Apache exactly what to do when it finds one of the above two filename extensions. It uses the alias defined in the first line to the directory containing the "php.exe" file.

Now Apache can work with PHP3, but ideally we then have to tell Apache that as well as the standard "index.htm/index.html" files which can be used for directory indices, that there are also now "index.phtml" and "index.php3" which should be treated the same way. This is also pretty simple. Just look through the "http.conf" file until you find the lines:

# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
DirectoryIndex index.html index.htm

Just update the last of these group so that it reads...

# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
DirectoryIndex index.html index.htm index.phtml index.php3

Configuring PHP3 for Apache and mySQL

At this point, mySQL is runing OK by itself, Apache knows about PHP3 but PHP3 still needs a slight bit of configuration to work with Apache. This is not anymore difficult than any of the other steps we've done. First of all you need to locate the sample "php.ini" file which was installed with PHP3 and should be in the "C:\php3\" directory. Rename this file so that it's called "php.ini" and copy it into your "C:\windows\" folder.

To get going with Apache you need to find the "Paths and Directories" section of the file, then update the "doc_root" parameter by entering the root directory used by Apache for webserving. If everything you'd done so far mirrors what we've done, this directory path will be:

doc_root = c:\progra~1\apache~1\apache\htdocs\

Note that because Windows 98 still doesn't completely get rid of these short filenames, the long filenames should be entered in a way in which DOS can still understand it. Also notice that unlike the Apache "httpd.conf" file, back-slashes are used as normal.

Next we need to update the "extension_dir" parameter so that it contains the path to where PHP3 has been installed, in this case, "c:\php3\".

extension_dir = c:\php3\ ; directory in which the loadable extensions (modules) reside

There's only one thing left to do now, and that is to make sure that PHP can load it's mySQL libraries. To do this, simply remove the semi-colon from the start of the line....

;extension=php3_mysql.dll

So that it reads

extension=php3_mysql.dll

One Last Thing

There is a file in your "C:\windows\" directory called "hosts.sam". Delete the filename extension from it, so that it's just called "hosts" and connections to your database will be much quicker. If neither a "hosts.sam" file or a "hosts" file is present, create a text file in Notepad and add the following line:

127.0.0.1    localhost

The spaces between the IP address and the name should be a "tab". Save this file in "C:\windows\" and call it "hosts".

You're Ready!

You should now have Apache, PHP3 and mySQL ready for action. If you haven't already done so, fire up mySQL by runing "c:\mysql\bin\mysqld". To start Apache, you can either run the program from the DOS prompt, or, use one of the shortcuts which are created for you when Apache installs. The one labelled "Start Apache as a Console App" is the one you're looking for in your "Start" menu.

How do I know it's worked?

The best way is to create a file in the "htdocs" directory in the "Apache" directory with a .php3 or .phtml extension, e.g. test.php3. Put the following PHP script into the file:

<?PHP
echo "Hello World";
?>

Then open your favourite web-browser and enter the following URL: http://localhost/test.php3.

Author: Mark Mitchenall
Who is this Tutorial for?

Anyone with an interest in learning how to setup PHP, mySQL and Apache on their Windows 98 machine. This tutorial is aimed at people who have a reasonable knowledge of DOS and Windows and who are familiar with what the three packages do. It does not go as far as to teach any of the three, there are plenty of resources on the Internet for that, and even a few books. This just kickstarts the installation process which the first time, can take some time.

All this tutorial does is shortcut all the documentation from the various vendors into a quick and dirty installation for Windows 98. As of the time of writing, the binaries used for our installation produced the results achieved in the tutorial, but this may change and I will do my utmost to ensure that this tutorial is up to date and correct.


Assumptions

This tutorial assumes that your Windows 98 machine is already set up for TCP/IP on a local area network. That's not to say that you need a local area network, it's just that you must have an IP address set up without needing to use Dialup Networking. For more information about this, consult your Windows Help Files.


Why would anyone want to do this on Windows 98?

A valid question, especially when it's free to install mySQL on Linux, and Windows 98 isn't exactly the operating system of choice for a lot of database professionals. The reason I give is simply that lots of people use Windows 98, moreso than Linux and Windows NT, and if you're familiar with Windows 98, it's probably one of the easiest to get going with. Lots of people may use one of the more heavy-weight OSs in everyday use, but have Windows 98 on their laptop or home computer.

Also, Windows 98 was the first operating system I installed this lot onto, and I was so impressed with how easy it was, and how quickly I could then get going with learning about the 3 packages, that I recommend that anyone who doesn't want to put Linux on their Windows 98 machine, stick with what they've got, pay the mySQL licence, and get going with 3 great tools which run perfectly adequately for initial development and learning purposes.


What do I get from doing this installation?

Installing the three packages gives you the ability to try out the industry standard webserver, along with an excellent medium strength database, and an excellent server-side scripting language on your Windows 98 PC. Although we haven't tried it ourselves, we're fairly confident that this could also be run quite happily on Virtual PC on the Macintosh. None of the applications takes a large amount of processor or memory resources and none have a GUI, so there's no reason why they shouldn't run fairly respectibly on this platform.

Once you have these three elements installed, all you need is a text editor to start creating dynamic database driven web-pages using PHP. Of course, if you've installed this on Windows 98, you've already got an adequate text editor, i.e. Notepad. For those of you who, like me, hate Notepad, there are some shareware alternatives we've tried out, but none that we've found so far which beat BBEdit on the Macintosh (especially when you consider that BBEdit Lite is completely freeware and is still better than any of the Windows based shareware offerings we've found, although the full product does PHP syntax highlighting which a major bonus). A good place to start looking for shareware and freeware products of this nature for all platforms is http://www.tucows.com.

So, you're fully armed to start PHP scripting with some database connectivity. Easy, wasn't it? Not only that, it's as fast, if not faster, than using Active Server Pages (ASP), just as cheap, and anything you develop on your local PC should be able to moved a Linux based website (which has PHP and mySQL) without any change in the HTML, PHP code or mySQL queries. The mitchenalll.com website is developed this way and the only thing which is changed between the local and the Linux based website is the line of code which contains the database login (the passwords are different on the two systems). Because we use PHP, this line is contained in a file which is simply included in every page which uses database connectivity, so all the actual PHP/HTML pages are identical between the local and the remote version.


Where can I find out more about these packages?

As stated in the tutorial, information about the three packages can be found at:

We also have some information and tutorials on using PHP and mySQL in our Library including links to other sites containing useful advice, samples and articles.


> Home > Resources > Articles & Tutorials > Non-Programming Articles

 
4D Solutions Partner Logo

Last modified: 19 December 2001 by webmaster@mitchenall.com

[Home]
[Services]
[Products]
[Resources]
-> Articles & Tutorials
* External Links
* Site Index
* Recommended Reading
[Contacts]
 
Toolbar Component Valid HTML 4.01!
© mitchenall.com
1999-2002
Valid CSS!