PHP, which stands for PHP: Hypertext Preprocessor, is a server-side scripting language designed for web development but also used as a general-purpose programming language. This tutorial is on how to manually install PHP on Windows 7.
Installation
- Go to http://windows.php.net/download/ to download PHP.
- Choose the zip file under PHP 5.3 – VC9 x86 Thread Safe.
- Extract the contents to D:\webserver\php.
Editing php.ini
- In the D:\webserver\php folder rename php.ini-development to php.ini and open it in notepad++ or your preferred text editor.
- Find and uncomment the extension_dir directive by removing the ; character. Change the value to:
extension_dir = "D:/webserver/php/ext"
- Next enable some extensions. This will depend on the libraries you want to use, but the following extensions should be suitable for the majority of applications (remove the semi-colon character):
extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll extension=php_xmlrpc.dll
- Optional. You might also want to increase the following values for development. Over the years, these values worked well for me. Tweak it as you like:
- Increase the maximum execution time of each script, in seconds, to 300:
max_execution_time = 300
- Increase the maximum amount of time spent parsing request data:
max_input_time = 300
- Increase the memory limit. Useful when testing memory intensive scripts:
memory_limit = 256M
- Increase max_input_vars. Useful when testing large HTML forms with many fields:
max_input_vars = 2000
- Increase the maximum size of POST data that PHP will accept:
post_max_size = 100M
- Increase the maximum allowed size for uploaded files:
upload_max_filesize = 50M
- Increase the maximum execution time of each script, in seconds, to 300:
- Save your php.ini.
Note: The above settings is for a local development web server. For production you need to choose your settings carefully. You might want to check the description of php.ini directives.
Adding PHP to Windows Path
This will allow Windows to find PHP globally by adding D:/webserver/php to the system path variable.
- To edit the path variable, press the Windows Key + R. In the run dialog type “SystemPropertiesAdvanced.exe” and hit enter.
- Click the “Environment Variables…” button.
- On the popup dialog under System Variables look for Path and edit it. Add this at the end:
;D:\webserver\php
Take note of the “;” which acts as a separator
- Click the OK buttons.
Adding PHP to Apache
- Open the Apache config: D:\webserver\apache\conf\httpd.conf
- Add index.php to the DirectoryIndex directive:
<IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
- At the end of httpd.conf append:
#PHP5 LoadModule php5_module "D:/webserver/php/php5apache2_4.dll" AddType application/x-httpd-php .php PHPIniDir "D:/webserver/php/"
- Save and restart windows.
Testing PHP
- Create a file in “D:/webserver/htdocs/” and name it hello.php
- Inside it place this code:
<?php phpinfo();
- Open your browser and go to http://localhost/hello.php.
No Comments