Complete walkthrough on how to setup Apache Web Server, PHP and access to a database on a PC on Windows XP.



I will be referencing this tutorial
http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml

Many web developers want to run Apache and PHP on their own computer
since it allows them to easily test their scripts and programs before
they put them "live" on the Internet.
I'm drilling down on the tutorial to
If you plan to use one of the Apache 2 or 2.2
web servers on Windows XP, see the tutorial

Ok now they are asking me what version of Apache my bluehost uses
It uses version 2.2.13 on Unix as of 11/05/2009
I think I'm safe to install the latest 2.2.14
I'm installing the
I got the Win32 Binary without crypto (no mod_ssl) (MSI Installer): apache_2.2.14-win32-x86-no_ssl.msi [PGP] [MD5] [SHA1]
I saved it to here
/home/el/wiki/files/windows_software/apache_web_server/apache_2.2.14-win32-x86-no_ssl.msi
Run the installer.
Reading through the "what is it" docs says we should look for an INSTALL.txt
the mod_ssl is a cryptography engine made by Ralf Engeshall. It's a module for the secure sockets layer (SSL).
When you arrive at the "Server Information" dialog box, enter "localhost" (without the quotes)
for the Network Domain as well as for the Server Name and whatever email address you wish for
the "Administrator's Email Address" field. The installer uses the information you enter to
create a default Apache configuration file for you. You can always go back and manually
change these values in your configuration file if you change your mind later. Leave the default
setting of "for All Users, on Port 80, as a Service" as it is. Click "Next" when you're done.
Choose Typical and you get this screen
Looks successful.
Configuring Apache to Accept Server Side Includes (SSI)

If you want the web server to parse Server Side Includes (SSI directives), search for the text "server-side includes" in the file. Add the following lines just after the block of text containing those words:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

Alternatively, you can uncomment the example text given in the
configuration file by removing the hash prefix ("#") before each
line.

Apache will now handle the SSI directives that occur in files with
names ending in ".shtml".

If you want "index.shtml" to be your default start page for your
directories, ie, if you want Apache to load "index.shtml" when you
type "localhost" or "localhost/directory/", you will need to search
for a line in your "httpd.conf" that begins with "DirectoryIndex" and
add index.shtml to the list of files there. For example, modify it
as follows:
DirectoryIndex index.shtml index.html
Adding it before index.html means that Apache will give preference to index.shtml if both are present.
Uncommenting:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

When I was testing it. Typing in "localhost" into the firefox browser it was
downloading a php file! This was because of Firefox Cache.
Clear it like this. on the left
OK now we install PHP5.
This tutorial asks for the zip package by name.
Here is the download.
/home/el/wiki/files/windows_software/php/php_5.3.0/php-5.3.0-Win32-VC9-x86.zip
Create a folder on your hard disk for PHP. I suggest
"c:\php" although you can use other names if you wish.
Personally though, I prefer to avoid names with spaces in it,
like "c:\Program Files\php" to avoid potential problems with programs
that cannot handle such things. I will assume that you used c:\php
in this tutorial.

Extract all the files from the zip package into that folder. To do that simply
double-click the zip file to open it, and drag all the files and folders to c:\php.
If you are upgrading to PHP 5 from an older version, go to
your windows directory, typically c:\windows, and delete any
php.ini file that you have previously placed there.

Go to the c:\php folder and make a copy of the file "php.ini-recommended".
Name the new file "php.ini". That is, you should now have a file "c:\php\php.ini",
identical in contents with "c:\php\php.ini-recommended".

Open the php.ini file:
Enable Short Open Tags

Search for the line that reads:
short_open_tag = Off

If short_open_tag is set to "off", tags like "<?" will
not be recognised as the start tag for a PHP script.
In such a case, to begin a PHP script, you will need to
code your script with an opening tag like "<< php". Since
many third party PHP scripts use "<?", setting this to "Off"
will give you more problems than it's worth,
particularly since most, if not all, commercial web hosts
that support PHP have no issues with your scripts using " this, change it to the following:
short_open_tag = On

I set it.
By default, input data is not escaped with backslashes. That is, if your visitors enter an inverted comma (single quote) into your web form, the script will receive that unadorned inverted comma (single quote). This is for the most part desirable unless you special requirements. If you want your input data to have the backslash ("\") prefix, such as, for example, to mimic your web host's settings, search for the following:
magic_quotes_gpc = Off

and replace it with:
magic_quotes_gpc = On

Do not do this unless your web host has this setting as well. Even with the setting of "Off", you can still use the addslashes() function in PHP to add the slashes for the specific pieces of data that need them.

I set it as recommended
intentionally blank. Register Globals

A number of older scripts assume that all data sent by a form will automatically have a PHP variable of the same name. For example, if your form has an input field with a name of "something", older PHP scripts assume that the PHP processor will automatically create a variable called $something that contains the value set in that field.

If you are running such scripts, you will need to look for the following field:
register_globals = Off

and change it to the following:
register_globals = On

WARNING: Do NOT do this unless you have third party scripts that need it. When writing new scripts, it's best to always code with the assumption that the register_globals item is set to "Off".

I'm not doing this.
Display Errors

On a "live" website, you typically want errors in your script to be silently logged to a PHP error file. On your own local machine, however, while you are testing and debugging a PHP script, it is probably more convenient to have error messages sent to the browser window when they appear. This way, you won't miss errors if you forget to check the error log file.

If you want PHP to display error messages in your browser window, look for the following:
display_errors = Off

And change it to:
display_errors = On

This value should always be set to "Off" for a "live" website

I'm setting it on.
Session Path

If your script uses sessions, look for the following line:
;session.save_path = "/tmp"

The session.save_path sets the folder where PHP saves its session files. Since "/tmp" does not exist on Windows, you will need to set it to a directory that does. One way is to create a folder called (say) "c:\tmp" (the way you created c:\php earlier), and point this setting to that folder. If you do that, change the line to the following:
session.save_path = "c:\tmp"

Notice that in addition to changing the path, I also removed the semi-colon (";") prefix from the line.

Alternatively, you can find out the current TEMP folder on your computer and use that. Or create a "tmp" folder in your PHP directory, like "c:\php\tmp" and set the configuration file accordingly. The possibilities are endless. If you can't decide, just create "c:\tmp" and do as I said above.

I did it
Intentionally blank SMTP Server

If your script uses the mail() function, and you want the function to successfully send mail on your local machine, look for the following section:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

Change it to point to your SMTP server and email account. For example, if your SMTP server is "mail.example.com" and your email address is "youremail@example.com", change the code to:
[mail function]
SMTP = mail.example.com
smtp_port = 25
sendmail_from = youremail@example.com

Note that after you do this, when your script tries to use the mail() function, you will need to be connected to your ISP for the function to succeed. If you do not modify the above lines and attempt to use mail() in your script, the function will return a fail code, and display (or log) the error (depending on how you configure php.ini to handle errors).

(Note that in Apache 1.x, the smtp_port line may not be present. If so, don't include it.)

I'm not doing this.
How to Configure Apache for PHP 5

There are two ways to set up Apache to use PHP: the first is to configure it to load the PHP interpreter as an Apache module. The second is to configure it to run the interpreter as a CGI binary. I will supply information for how you can accomplish both, but you should only implement one of these methods. Choose the module method if your web host also installed PHP as an Apache module, and use the CGI method if they have implemented it to run as a CGI binary.
I am going to run PHP 5 as an Apache Module

Add this:
LoadModule php5_module "c:/php/php5apache2_2.dll"

Note carefully the use of the forward slash character ("/") instead of the traditional Windows backslash ("\"). This is not a typographical error.
Next, search for "AddType" in the file, and add the following line after the last "AddType" statement. Do this no matter which version of Apache you are using. For Apache 2.2.x, you can find the "AddType" lines in the < IfModule mime_module > section. Add the line just before the closing < /IfModule > for that section.
AddType application/x-httpd-php .php

I did this.
Finally, for those using one of the Apache 2 versions, you will need to indicate the location of your PHP ini file. Add the following line to the end of your httpd.conf file.
PHPIniDir "c:/php"

Of course if you used a different directory for your PHP installation, you will need to change "c:/php" to that path. Remember to use the forward slash ("/") here again.

I did this.
If you create a file index.php, and want Apache to load it as the directory index page for your website, you will have to add another line to the "httpd.conf" file. To do this, look for the line in the file that begins with "DirectoryIndex" and add "index.php" to the list of files on that line. For example, if the line used to be:
DirectoryIndex index.html

change it to:
DirectoryIndex index.php index.html

The next time you access your web server with just a directory name, like "localhost" or "localhost/directory/", Apache will send whatever your index.php script outputs, or if index.php is not available, the contents of index.html.

I did this.

Now tutorial says Restart the Server and make your hello world php file in htdocs
That looks right.

Good now lets do MySQL.
I have to get the MySQL Community Server because I dont want to pay $600 per year per server
After some google research, the "Windows Essentials" is barebones, but the "Windows MSI Installer"
Is the Developers version with bells and whistles.
It's asking me to login to get it. No I don't want any
girl scout cookies for $5 a box.
Proceeding with Registration.
This will take a while. Play a videogame while it downloads
Ok The download is done, stored in:
/home/el/wiki/files/windows_software/mysql/mysql-5.1.40-win32.msi
It says run the install file and
install it where you like, doesn't make much difference.
Choose Complete.
Looks like it installed to C:\Program Files\MySQL\MySQL Server 5.1\
and data folder
C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\

Ha, thought you wre done? NO.
Go to start MySQL and command line and enter password.
In the console, typing help. seems to work.
Ok the command mysql_connect is not working.
Did a google search for: "Call to undefined function mysql_connect()"
Clicked the one near the bottom "PHPFreaks" site is really good
This is:
http://www.phpfreaks.com/forums/...
Basically you have to Fiddle with php.ini in your C:\php folder.
I had to change this line.
I had to change this line.
This is better! Now we just can't see the database!
Well now we have to configure the database
I want to try out a whole bunch of database tools
1. Squirrel database software worked but it was clunky
2. PhpMyAdmin

Lets try PHPMyAdmin first.

We will use this tutorial
http://www.wikihow.com/Install-phpMyAdmin
Hard copy of the above directions:
/home/el/wiki/knol/installing_php_myadmin

Go to this website
http://www.phpmyadmin.net/home_page/downloads.php

Here is the downloaded file:
/home/el/wiki/files/windows_software/phpMyAdmin/phpMyAdmin-3.2.3-english.zip
Extract the contents into htdocs of apache
But rename the top level file to 'phpmyadmin' all lowercase
It should look like this
Yay, it works
Keep going with the tutorial
Login In.
Boom, we are there. We are up and running and accessing my databases.
The databases are SET.