For all those who don't know, PHP and MySQL are the dynamic duo- like Bonnie and Clyde or pasta and marinara sauce; together, they serve up dynamic web pages faster than the blink of an eye. The best part? They are completely free. Free like free beer, free like free speech, free like... well, you get the point. You can download both and pay nothing. Put them on as many machines as you can, and run them from now until the time your computers die. It doesn't matter.
Now, I'm sure anyone who is interested in PHP is wondering, "What is that? I've never heard of that, I bet nobody uses it." Guess again- any site you see with something like .php3 or .php, or .phtml in the header location is running PHP. You may also be thinking, "Ok, PHP is out there, but MySQL? Is that like Microsoft's SQL? If not, why not just stick with Microsoft SQL?" Well, the thing is, you can do just that because PHP will support MS SQL, and it works fine; but, why would you want free beer but have to pay for the glass? Is pasta the same without marinara sauce?
So, you've got a Windows machine, and you want to give this a shot. You've heard from some people that PHP and MySQL only run on Linux or UNIX machines. Well, bonk them in the head if you want to, because they're wrong- they don't have their facts straight.
Step one, download the MySQL installer:
MySQL for Windows 98/NT/2000
You will need WinZip to extract this file. I recommend saving it to a folder "MySQL" on your desktop. From there, open the folder and run setup.exe inside. Yep, that's right- it's a GUI interface for installing MySQL. Who would have thought? Anyone who is familiar with Windows 98/NT/2000, will be familiar with this type of installation. Remember where you set it to install; you'll need to know later. Let it do its thing. Maybe take a break and get a cup of coffee (you might need it for any coding you'll do later).
After you click through all the hullabaloo and the install in finished, it's time to get MySQL running. Go to the directory in which you installed MySQL- in my case, C:\mysql. From there, go into the "bin" directory. You should see a program, "winmysqladmin.exe". Later, you might want to add this to your start menu, but if you notice, this is a graphical interface to MySQL! It shows you configuration options, startup checks, tables, databases and other funky things. If you notice, it will also start up the MySQL server on your machine. When it first starts up, it'll ask you for a username and password- but, this is the username and password that you want to have for the administrator account of this database. So, put in your desired username and password, with care to remember both- you'll need them later, for coding.
Well, now you have MySQL running (along with WinMySQLAdmin). You should see a little stoplight in your systray, and if you click once on it, a menu comes up. Mess around with it- you're all smart people, I'm sure you'll figure it out.
Next up, we need Apache. Apache is going to be the webserver that serves all of our web documents. We could go with IIS, but, we're focusing on open technologies here- and, personally, I don't feel like risking the security of my computer by putting IIS on it. Once again, there is a port of Apache to Windows 98/NT/2000, and it, too, has a graphical install! Since you'll need it, get it below:
Apache 1.3.20 for Windows
Download this package, and once again, save it wherever you'd like. When it's done, open up the installer package. Read through it- it's actually put together pretty well for a Windows installer. Gotta dig that logo! There will be some things it will ask you- such as domain name, server name, and an E-mail account for the adminstrator of the server. Just put everything in as needed. It will ask you if it should be installed as a service or as a per-user application. When you install on a production server, choosing as a service is probably best. For this example, let's leave it as an executable.
Now, you should be all set with MySQL and you now have Apache installed. Now let's fire this puppy up; go into your "Start" menu, and under "Apache HTTPD Server" click the "Start Apache in Console". A window will come up, it should say something like "Apache 1.3.20 (win32) Running". Now, this means your Apache server is running; but, just to make sure, open up your web browser and type in "127.0.0.1". You should be presented with the basic Apache startup page. If you don't have that, then you missed something along the way. Uninstall and try again. (If you still are having massive problems, E-mail me at rebelpacket@asleep.net, and I'll try to help you).
So far, we have our database server (MySQL) up and rocking, and we have Apache cooking, too. All we need now is the final piece of our metaphorical pie: PHP.
Let's get the PHP installer (yes, even PHP has a graphical installer program) from the link listed below:
PHP 4.05 for Windows
Save that file, and then to unzip it a new directory. You'll need to create this directory. So, open up your C:\ drive and make a new folder called php.
From there, using your unzip tool, extract all the files to the C:\php\ directory. When you are done with that, open up C:\php\. Right click on the file you see called php4ts.dll. Copy that file, and then go into your C:\windows\system\ folder, and paste it. PHP is now installed.
Click your "Start" menu, go to "Programs", and "Apache HTTPD Server", and then "Configure Apache Server" and then click where it says "Edit Httpd.conf Apache Configuration File". This will ask you what program you want to use to open up the httpd.conf file. I just use notepad- fast, quick, easy; gets the job done.
Scroll down, without changing anything, until you see a section with a whole bunch of LoadModules on the left. Should be a row of like 5-10 or more. When you find this section, right after the last LoadModule, on a new line, insert the line shown below, exactly as it appears:
LoadModule php4_module c:/php/sapi/php4apache.dll
Once you have done this scroll down until you see the following lines:
# And for PHP 4.x, use:
#
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps
What you want to do here is remove the # from the front of the first AddType string and remove the entire second line (AddType application/x-httpd-php-source .phps). Append .phtml to the uncommented line- you want it to look exactly like what you see below:
# And for PHP 4.x, use:
#
AddType application/x-httpd-php .php .phtml
#AddType application/x-httpd-php-source .phps
After you have made these changes, save and close. Close the Apache server console (if you had it open), and start it up again. Create a file in your Apache html root directory <where you installed Apache>/Apache/htdocs/ called phpinfo.php and put the following lines in it, below:
<?php
phpinfo();
?>
Save that file, with the lines above in it, and close it. Open your web browser, and point it to http://127.0.0.1/phpinfo.php. You should get a very funky cool PHP screen, showing you all the configuration options that are included in and with PHP. If you don't, then attempt to restart Apache. If you're still having issues then something went horribly awry. Look over the instructions again, and if you still have questions, E-mail me at rebelpacket@asleep.net.
Enjoy PHP, MySQL, and Apache on your newfound development workstation!