Custom Search
 


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

  1. Go to http://www.php.net/downloads.php

  2. Find the URL that links to Windows binaries download page and click it to open the relevant downloads for Windows operating system.

  3. 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
MD5 hash provided by PHP: 7040598a802d56dbda00bb8361ea5c7b

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.1 Welcome

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.
(Go to Start -> Settings -> Control Panel -> System -> click Advanced tab -> click Environment Variables button)

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:

Purpose Old value New value
Enables the short tag <? and ?> instead of <?php and ?> short_open_tag = Off short_open_tag = On
Always display errors display_errors = Off display_errors = On
Turn on debugging on startup errors display_startup_errors = Off display_startup_errors = On
Create temporary directory for HTTP uploaded files such as uploaded photos ;upload_tmp_dir = upload_tmp_dir = "C:\Program Files\PHP\uploadtemp"

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:

<?
echo phpinfo();
?>

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.

PHP Info

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.

Happy Installing!


Copyright© GeeksEngine.com



Related Articles:

1.How to install Apache 2.x web server on Windows
2.How to connect two different versions of MySQL server on the same computer
3.How to configure MySQL server 5.1 on Windows
4.How to install MySQL server 5.1 on Windows with screenshots
5.Five ways to create include path for PHP
6.How to use Date and Time data as integer value in PHP and MySQL
7.How to use Apache Virtual Host to run multiple local websites on Windows
8.Install all PEAR packages by yourself
9.How to install PEAR on Windows
10.How to use PHP and Microsoft SMTP Virtual Server to send emails
11.How to install PHP server-side scripting language on Windows
12.How to install Apache 1.3 web server on Windows
13.How to install two different versions of MySQL server on the same PC
14.How to configure MySQL server 4.1 on Windows
15.How to install MySQL server 4.1 on Windows with screenshots
16.Export Northwind Access database to MySQL via ODBC


Other Recent Articles from the WAMP & LAMP category:

1.How to install MySQL Server 8 on Windows
2.How to resolve Apache web server port 80 access problem
3.The free tools I use to build PHP and MySQL websites
4.How to install Apache 2.x web server on Windows
5.How to connect two different versions of MySQL server on the same computer
6.How to configure MySQL server 5.1 on Windows
7.How to install MySQL server 5.1 on Windows with screenshots
8.How to upgrade from PHP4 to PHP5
9.How to load time zone data for MySQL on Windows
10.How to use Apache Virtual Host to run multiple local websites on Windows
11.Install all PEAR packages by yourself
12.How to install PEAR on Windows
13.How to use PHP and Microsoft SMTP Virtual Server to send emails
14.How to install PHP server-side scripting language on Windows
15.How to install Apache 1.3 web server on Windows
16.How to install two different versions of MySQL server on the same PC
17.How to configure MySQL server 4.1 on Windows
18.How to install MySQL server 4.1 on Windows with screenshots
19.How to set up DSN in ODBC Data Source Administrator on Windows

Copyright © 2024 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.

 
Home | Feedback | Terms of Use | Privacy Policy