Tuesday, September 20, 2011

Configuring PHP Development Environment in Windows

Apache HTTP Server



  1. Download the Apache2 HTTP server.

  2. Run the installation file .msi. The installation wizard starts. Follow the instructions.On Microsoft Vista, do not install the Apache Server to the default location, which is in Program Files. All files in Program Files are write-protected.

  3. When the installation is completed, restart the Apache server.

  4. To check that the installation is successful, run the browser and enter the following URL:
      http://localhost/

    The Apache welcome test page opens:
    Apache web server test page indicates that Apache is running


Troubleshooting


By default, the Apache server listens to port 80. This port can be already used by other services, for example Skype. To solve the issue, change the port which the server listens to:

  1. Open the Apache web server configuration file httpd.conf. By default the file is located in C:\Program Files\Apache Software Foundation\Apache<version>\conf\

  2. Locate the line Listen 80 and change the port number, for example 8080. Save the file.

  3. Restart the Apache web server.

  4. To check that the web server works, run the browser and enter the URL and specify the port number explicitly: http://localhost:8080


You can also stop the processes that possibly listen to port 80. In the Task Manager, select the relevant file name and click End Process.

Find more information on installing and configuring the server here.

PHP Engine



  1. Download the PHP5 engine.

  2. When the download is complete, run the .msi installation file. The installation wizard starts.

  3. On the Apache Configuration Directory panel, specify the directory where the httpd.conf file is located, the default setting is C:\Program Files\Apache Software Foundation\Apache<version>\conf\. The PHP processing will be enabled automatically.

  4. If you want to use the MySQL database server, choose the Complete installation option or select the MySQL and MySQLi items in the Extensions list.

  5. After the installation is completed, restart the Apache server.

  6. To check that the PHP engine has been installed successfully and PHP processing has been enabled in the Apache configuration:

    • In the Notepad, create a file and type the following text:
      <?php
      echo "PHP has been installed successfully!";
      ?>


    • Save the file in the htdocs folder: C:\Program Files\Apache Software Foundation\Apache<version>\htdocs\test.php

    • Run the browser and enter the following URL: http://localhost:<port>/test.php. The following page opens:
      PHP test page indicates that the PHP engine is enabled




Troubleshooting


If the page does not open:

  1. Restart the Apache server.

  2. Check that the Apache server configuration file httpd.conf contains the following lines:
      AddType Application/x-httpd-php .php
    LoadModule php5_module "c:/php/sapi/php5apache2_2.dll"


  3. If the lines are missing, add them, save httpd.conf, and restart Apache.

  4. Refresh the http://localhost:<port>/test.php page.


Source: http://netbeans.org/kb/docs/php/configure-php-environment-windows.html#installComponentsSeparately