Tutorial: Installing Apache and PHP Under Win32
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
To the Reader: You may wonder why I chose this tutorial. Well, I am often asked how to work with a language that is usually server-based, like PERL or PHP, on a personal computer. When Dennis Wrennsent this great piece along, I knew it would be quite technical and make a few people nervous, but will be quite helpful to those who want to look into PHP and all it offers. Good luck with it. I hope you find it helpful.
By: Dennis Wrenn
Here is a complete, easy to follow tutorial on how to install Apache Web Server, and PHP on a Win32 Operating System.
Good question, PHP is a server side web programming language. Its purpose is very similar to ASP, but in my opinion, it's better. There are more databases available to use with it and ASP can only communicate with Access and SQL servers. PHP can communicate with SQL Server, MySQL, mSQL, and several others, but that is not the topic of this tutorial.
Another good question, Apache is a web server, similar to PWS, and IIS. They, and it, listen(s) on a specific port (usually it's 80) and allow you to run a website off of your home computer. Neat, Eh?
First you need to download Apache Do that here. It's fairly large (about 3.6mb), so be patient. After downloading, double click the exe. Installing is a breeze, but configuring isn't that easy.
Move to your apache directory after installing. It's usually C:\Program Files\Apache Group\Apache. Look for, and open, a folder called conf. Open the file called httpd.conf. It may look cryptic and confusing at first, but about half the file is made up of comments, which begin with a "#" mark.
The parts in red need to be found, and the parts in greenneed to be changed or added. (NOTE: I removed all the file comments for the sake of size - those comments shown below are there just as a guide for you.)
#NOTE: you can change c:/website #to anything you want, that is just #happens to be where I store my files. #Another NOTE: All slashes must be forward / <Directory /> Options FollowSymLinks ExecCGI AllowOverride None </Directory> <
> Order allow,deny Allow from all </Directory>
After changing that, place a file (we'll call ours filename.htm) to the document root you set. Then start Apache (by clicking Start button -> Program Files -> Apache -> Management -> Start Apache). Now use your favorite browser, and type in:
You should get your file. Cool. If so, keep reading. If not, then email meand tell me what the problem is. Be sure to send the complete httpd.conf file.
This part is fairly easy, the PHP homepage is php.net, you can download the CGI executable, or the ISAPI DLL's for PWS and IIS. But we won't be downloading from php.net. Go to php4win.de and download PHP 4.04. This file is quite big too. So, again, be patient. Now, unzip the file to C:\php.
Stop Apache, if it isn't already. Copy php4ts.dll to the Windows\System directory. In httpd.conf search for #LoadModuleit should bring you to a list of modules that can be loaded. Leave those alone, but directly under them, add these lines:
LoadModule php4_module c:/php/sapi/php4apache.dll
AddType application/x-httpd-php .php
Now, write a file called test.php, with this as the content:
echo "PHP Rules!";
Save the file, and put it into the directory you set as the document root. You set that up above. Now start up Apache, and type this into the location bar of your favorite web browser:
If all goes well, you should get a lovely:
...on the screen. Well, did you? If so, great. If not, email meany problems you have, and I will see if I can help you.
Well, that is up to you, I would recommend reading the PHP Manual, and accelerating your PHP skills.