featured

How to Manually Install PHP on Windows

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

  1. Go to http://windows.php.net/download/ to download PHP.
  2. Choose the zip file under PHP 5.3 - VC9 x86 Thread Safe.
  3. Extract the contents to D:\webserver\php.
    Extracted zip

    Extracted zip

Editing php.ini

  1. In the D:\webserver\php folder rename php.ini-development to php.ini and open it in notepad++ or your preferred text editor.
  2. Find and uncomment the extension_dir directive by removing the ; character. Change the value to:
    extension_dir = "D:/webserver/php/ext"
  3. 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
  4. 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:
    1. Increase the maximum execution time of each script, in seconds, to 300:
      max_execution_time = 300
    2. Increase the maximum amount of time spent parsing request data:
      max_input_time = 300
    3. Increase the memory limit. Useful when testing memory intensive scripts:
      memory_limit = 256M
    4. Increase max_input_vars. Useful when testing large HTML forms with many fields:
      max_input_vars = 2000
    5. Increase the maximum size of POST data that PHP will accept:
      post_max_size = 100M
    6. Increase the maximum allowed size for uploaded files:
      upload_max_filesize = 50M
  5. 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.

  1. To edit the path variable, press the Windows Key + R. In the run dialog type "SystemPropertiesAdvanced.exe" and hit enter.
  2. Click the "Environment Variables…" button.
    php2
  3. 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

    Editing path

    Editing path


    Adding the PHP path

    Adding the PHP path

  4. Click the OK buttons.

Adding PHP to Apache

  1. Open the Apache config: D:\webserver\apache\conf\httpd.conf
  2. Add index.php to the DirectoryIndex directive:
    <IfModule dir_module>
    	DirectoryIndex index.html index.php
    </IfModule>
  3. 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/"
  4. Save and restart windows.

Testing PHP

  1. Create a file in "D:/webserver/htdocs/" and name it hello.php
  2. Inside it place this code:
    <?php phpinfo();
  3. Open your browser and go to http://localhost/hello.php.
    PHP working

    PHP working

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php