Archive
This post is archived and may contain outdated information. It has been set to 'noindex' and should stop showing up in search results.
How to Install the Latest PHP on Windows
Mar 5, 2014Web DevelopmentComments (0)
This is a quick and easy guide for installing the latest version of PHP on your Windows computer. You need to already have the Apache httpd server. If you don't yet, please follow the Apache Windows installation guide first. This PHP guide was written specifically for Windows 7, but the steps should be similar for Windows 8 and other versions.


Step 1


Download the latest version of PHP from the Windows PHP download page. Choose the VC11 Thread Safe zip file download (x86 if you have 32-bit Windows or x64 if you have 64-bit Windows). At the time of writing, PHP 5.5.10 is the latest version. If you have a newer version, you should be able to simply substitute it, unless major changes have been made.


Step 2


You should now have a zip file named php-5.5.10-Win32-VC11-x64.zip or similar in your download folder. Extract its contents to a new folder called PHP 5.5.10 inside your Program Files folder. The path should look like:

C:/Program Files/PHP 5.5.10
This folder should contain the php-cgi.exe file. From this point on I'll assume you have PHP in the same folder. If not, adjust accordingly.


Step 3


Now to configure PHP. Inside the PHP 5.5.10 folder is a file called php.ini-production. Make a copy of it and rename the copy to php.ini. This will be your main configuration file. Open php.ini in a text editor as you'll need to make a handful of edits:

Timezone
Fine the line that has date.timezone in it (approximately line 914). Remove the preceding semi-colon to uncomment the line, and add your timezone. For a list of available timezones, see the PHP timezone list. My line looks like:

date.timezone = America/Los_Angeles
Windows Extensions
Find the line that has Windows Extensions in it (approximately line 858). Below that you'll see a bunch of lines that start with ;extension. These are all optional extensions that are commented out (disabled by the semi-colon). Remove the semi-colon to enable any that you may want. Commonly used ones are php_curl, php_gd2, php_mbstring, php_mysqli, and php_pdo_mysql.

Find the line that has extension_dir = "ext" in it (approximately line 722). It should be preceded by a semi-colon. Remove the semi-colon to uncomment out the line and enable it. Now PHP will know where to find the extensions (this is the default location).

Temporary Directory
Find the line that has sys_temp_dir in it (approximately line 726) and change it to:

sys_temp_dir = "C:/Users/YOUR_USER_NAME/AppData/Local/Temp"
This temp location is less prone to permissions errors than the default (system) temporary directory.

Sessions
If you want to use PHP sessions, you'll want to make sure the temporary folder that PHP saves session files to is accessible. This can be found in the line that contains session.save_path (approximately line 1391). Something like this should be safe:

session.save_path = "C:/Users/YOUR_USER_NAME/AppData/Local/Temp"

Step 4


Now you need to add PHP to the Apache httpd.conf file. Open httpd.conf and scroll to the very bottom. Add a few blank lines and then add:

#BEGIN PHP
<Directory "C:/Program Files/PHP 5.5.10">
AllowOverride all
Require all granted
</Directory>
ScriptAlias /php/ "C:/Program Files/PHP 5.5.10/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
#END PHP

This tells Apache where to find PHP. Also, be sure to add index.php to the DirectoryIndex listing in httpd.conf if you haven't yet.

You should now be able to start your Apache server and it will parse PHP files!
Comments (0)
Add a Comment
No comments yet