How to install PHP on Windows

Now for this issue of MKmA, I will be helping you on how to install PHP on your Windows. This kind of late, I know but then again better late than never, aight!

Let’s start installing PHP now, in my case I am using the Windows XP but this one also works in Vista. So let’s get starting now. And let’s make it specific, we are going to install the manual process using the zip file. Installer version is unreliable as it missing some of the files and libraries as you go along with your work. Most developers preferred the zip file anyways.

  1. Download the zip file
    To download, go to this link, if you notice in the left corner of the download page there’s a caption that reads “Which version do I choose?”. It says that if you are using PHP with Apache 1 & 2, you have to download the VC6 version but if you’re using an environment that runs in an IIS platform then choose the VC9. And as posted in my previous entry, I help you with the installation process using the Apache 2.2.

    So we will be using the VC6 version and why not the VC9? Well, according to the expert (I am not one of them unfortunately, lol), VC9 was compiled with C++ version 9 or the commercially and popularly known as the Visual Studio 2008. It said that this version have lots of improvements when it comes to performance and stability but this version only works for the IIS environment and not for the Apache which was compiled using the Visual Studio 6, hence the name VC6.

    For the thread safe and non thread safe option. Windows uses the thread to processor model architecture unlike in Unix/Linux system that uses process to processor model. Apache requires thread safe binaries for modules while CGI uses and benefits from non thread safe binaries. For the reason that Apache modules are threaded from a single executable while CGI launches executable for every request.

    So if you’re using Apache module then download the VC6 Thread Safe but if you’re using the Apache CGI, VC6 Non Thread Safe is the right binary for you.

    And because we are using the Apache module, then we are going to download the VC6 Thread Safe. The filename should be like this php-5.3.3-win32-vc6-x86.zip.
  2. Extract the file
    Extract the distribution file by creating a folder to C:\php. PHP can be installed anywhere on your system but you will need to change the paths referenced. In this example we extract the distribution or the zip by creating a folder c:\php.
  3. Configure php.ini
    From the extracted file on your c:\php locate the file named php.ini-development and rename it to php.ini.
    • Open your php.ini, we are going to set the extension directory. Find the extension_dir = “ext” and change it to extension_dir = “C:\php\ext”.
    • We can also enable some of the extensions for future use but if you want to leave it as it is then it’s okay. But for example we want to change it right now, here’s the common DLLs to enable: You can enable this by deleting the semi-colon appeared before the extension filename.
  4. Add C:\php to the path environment variable
    This is to ensure Windows can find PHP, you need to change the path environment variable. You can do this through the Control Panel, choose System, then select Advanced and look for the Environment Variables button located at the bottom of the window box. Scroll down the System variables list and click “path” followed by the Edit button. Append this line ;C:\php at the end of the variable value line and click ok (remember the semi-colon).
  5. Configure PHP as an Apache module
    Make sure to stop your Apache service before doing this, you can either stop Apache server by clicking the icon on the icon tray or from the command line type this, net stop Apache2.2 and enter.

    Now open the Apache configuration by going through this folder C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf. At line 239 you find the DirectoryIndex now change it with this exact line DirectoryIndex index.php index.html.

    After changing the index directory scroll your cursor on the very last line of the config file and add this code:
    Save the config file now.
  6. Testing
    To test if its working, you have to restart or start the Apache if it is being stopped. Now create a php file with this filename test.php and type this three lines:
    Then load test.php in your browser by typing http://localhost/test.php. You should get a whole long list of php variables, settings and etc.

Haaaah! It’s long lol. But that’s it kid, I hope I’m of help lol!

P.S.
Use php editor to create .php file. Do not use notepad it won't work, it would give you a .php.txt file format, browser won't recognize it as a valid .php file.