Steps to install PHP 5.x on Windows as a development machine
This article is part of the article series of installing MySQL, Apache, and PHP on Windows (XP, Vista, Windows 7). If you haven't installed Apache web server, please install it now How to install Apache 2.x web server on Windows.
Here is How to Install MySQL 5.x which is part of the WAMP.
Step #1: Download PHP 5.x Windows Binaries
If the latest version does not provide an installer download, move a bit further down on the page to find a link that allows you to download the installer. It is roughly a 20MB file. In this article, we used PHP 5.2.14 to demonstrate.
Step #2: Verify the installer you just downloaded.
PHP download comes with a MD5 hash value. This hash value is a Checksum value that can be used to verify data and file integrity. Screenshot below shows the PHP installer I downloaded was verified by freeware HashCalc.
File downloaded: php-5.2.12-win32-installer.msi
Verified PHP download by HashCalc
Step #3: Start installation of PHP 5.x
Double click the installation file. The installation should start straight away.
Here are all the screenshots for each step of the installation process.
3.2 License Agreement
3.3 Web server setup
We select Apache 2.2.x Module because we already installed Apache web server. See this article How to install Apache 2.x web server on Windows.
3.4 Directory of Apache configuration file.
PHP installation needs to know where Apache configuration file located in order to add some PHP related values in that file.
Click Browse button to select the directory containing the Apache Configuration Files.
The screenshot below shows the Apache Configuration Files directory. Click OK to close this window.
Now the Apache Configuration Files directory is put in the text box. Click Next to continue.
3.5 Select extra libraries you want to PHP to install.
In this step, PHP installs extra libraries that enable PHP interact with other systems like MySQL.
Make sure you select the common ones such as GD2 (for image manipulation), MySQL, MySQLi, or any others you think are relevant to your development.
For example, here MySQL is selected and will be installed.
3.6 Ready to install PHP
3.7 Installation is in progress
3.8 Installation is completed
Step #4: Restart your computer
For Windows Vista and Windows 7, no need to restart your computer.
For Windows XP users, this step is extremely important. If you don't restart your computer, Apache web server can't be started. This is because PHP installation automatically added two Environment Variables in windows and these new entries won't take effect until you restart your computer.
Here are the two Environment Variables added by PHP installation.
Here is the error in Event Viewer if you try to start Apache without restarting your computer.
"The Apache2.2 service terminated with service-specific error 1 (0x1)."
Step #5: Configure php.ini file
Some values in PHP's configuration file (php.ini) needs to be modified.
Open php.ini in your text editor and modify the values (if the value is different to the new value) listed in table below.
Start -> Program Files -> PHP 5 -> php.ini
Because we are building a development and debugging environment, most of the default values in php.ini should be OK to use. Depending on your needs, you may want to change the following options:
Also, make sure the folder for saving session values is available on your computer. The session folder is defined in PHP.ini file. For example, if its value is session.save_path="C:\WINNT\Temp", you need to check if folder C:\WINNT\Temp exists on your PC. If not, create it. Otherwise, you'll never be able to use the session support in PHP.
Session value is used to validate a particular session such as a login session. When you call session_start() in PHP, it will create a session file in this folder. You can open the session file to examine values in it.
Step #6: Configure Apache configuration file
Apache Configuration File is located at C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf. It can also be opened from the Start menu as below.
Open the Apache configuration file and find the following line of text. It should be at the end of the file. Move it to the end of the LoadModule section.
LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"
Here is the how it looks after the move.
Step #7: Start Apache web server
After you restart your computer, start Apache Server from Windows Start -> Programs -> Apache HTTP Server -> Control Apache Server.
If Control Apache Server menu is not available. You can start, stop, and restart Apache by using Microsoft Management Console.
Start -> Settings -> Control Panel -> Administrative Tools -> Services
By using Windows Services, You can Start, Stop, and Restart Apache from Microsoft Management Console. See screenshot below. Selecting Apache as a Windows service will make it automatically start when your computer starts up, and to keep Apache running when you log-off.
Step #8: Test PHP
Create an index.php page under C:\test folder (Note that we created this folder when installing Apache as the DocumentRoot directory for Apache).
Add the following code inside your C:\test\index.php page and save it:
Step #9: Execute index.php page
Open your web browser and type http://localhost/index.php in the address bar, then hit Enter key. You should see PHP Configuration information page. Apache parses the index.php page and execute PHP function phoinfo() to load the content of php.ini file into your web browser.
If you can see the PHP Configuration page, both PHP and Apache have been installed correctly and you are on your way to create your first PHP website.
Copyright © 2017 GeeksEngine.com. All Rights Reserved.
This website is hosted by HostGator.
No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it.