| > Home > Resources > Articles & Tutorials > Non-Programming Articles |
|
|
Setting up Apache, PHP3 and mySQL on Windows 98 in 15 MinutesThis 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 installationInstall 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:
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 PHP3Apache 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/" 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 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 Configuring PHP3 for Apache and mySQLAt 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 ThingThere 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 Then open your favourite web-browser and enter the following URL: http://localhost/test.php3.
Author: Mark Mitchenall
|
|
|||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| > Home > Resources > Articles & Tutorials > Non-Programming Articles |
|
Last modified: 19 December 2001 by webmaster@mitchenall.com
|
|||||||||||||
|
||||||||||||||