ServersReal-World Windows 2000 Configuration: Getting Apache, PHP, MySQL, and phpMyAdmin to...

Real-World Windows 2000 Configuration: Getting Apache, PHP, MySQL, and phpMyAdmin to Work Together, Part 1 Page 3

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

The Server-Side Scripting Language: PHP – Installation and Configuration

PHP is a very capable server-side Web-oriented scripting language used on many Web sites. Its usage is growing as are its capabilities. It is browser independent, and cross-platform.

You can obtain the latest stable release of PHP at If you are interested in development versions of the next Windows release, go to If you are looking for past release builds for Windows go to Online documentation for installation on Windows, with user comments, is available at The file install.txt that comes with the distribution also explains PHP installation on Windows.

Another good source of installation information is the User Contributed Notes at the bottom of the online PHP documentation page for installing PHP on Apache: Documentation for offline use can be downloaded from A good way to keep up with PHP developments is to read the PHP Weekly Summary at

This tutorial, however, is about installing PHP as an Apache module. A module takes advantage of the Web server’s native Server API, or SAPI. PHP as a module runs faster than PHP as a stand-alone CGI script, but on Windows it has been said that SAPI support is not as stable — although I haven’t experienced any problems with my small-scale use of PHP as an Apache module on Windows.

To install PHP, extract the files and folders from the download, For the sake of this article, I will assume that these extracted files are contained in a top-level folder titled php (rename the extracted folder php-4.2.2-Win32 to php). Like the Apache folder, put it at the root of the C: drive. Thus, the path to the folder is C:php.

Then, copy the file php4ts.dll from C:php into C:WINNTsystem32. Also, copy the mibs folder from C:php into C:usr (you may need to create the usr folder first).

The recommended configuration settings for PHP are given in the file php.ini-recommended, which is located in the php directory. To create the actual PHP configuration file that you will be using, you can copy php.ini-recommended, edit it, and rename it to php.ini. The php.ini file must be located in the C:WINNT directory.

The following are the significant changes that I made to php.ini:

Changes to php.ini

short_open_tag = Off

display_errors = On


include_path = ".;C:phpinc"

doc_root = C:Apachehtdocs

extension_dir = C:phpextensions

file_uploads = Off = C:php_log

session.save_path = C:tempsessions

session.cookie_path =

session.cookie_secure = 1

Here are some comments on the changes noted above:

I turned off short_open_tag so that I could serve XHTML files, which begin with something like:

I turned display_errors to On to help with development. For production sites, it is recommended for security reasons that this be set to Off.

I created a directory C:tempsessions to hold temporary session files.

For greater security, and for load balancing on larger sites, session data can be stored in a database rather than in files. This requires additional work, however, as the the custom session handling functions must be set up.

The following four references provide additional information (note that in the examples register_globals are On):

For a basic explanation on using include files see I put my include files (*.inc) in C:phpinc, outside of Apache’s htdocs folder, for security reasons.

As can be seen from the configuration file, I created the directory C:php_log to store my PHP error log, php_errors.log.

I used a directive, session.cookie_secure = 1 that ensures session cookies are sent only when SSL connections are available. If you need to use cookies in a non-SSL (i.e., regular) browser session, do not use this directive.


The recommended configuration of PHP has register_globals set to Off, and I did not change that. This is done to make PHP more secure. The consequence; however, is scripts that were written based on register_globals set to On will not work properly until they are rewritten.

With register_globals set to Off, session variables can be accessed via the array variable $_SESSION, which is one of the superglobal arrays. For further information on register_globals, global variables, and superglobal arrays see:

By the way, I “experimented” with using the least number of files to run basic PHP and found out that it runs with just four files: C:phpphp.exe, C:phpsapiphp4apache.dll, C:WINNTphp.ini, and C:WINNTsystem32php4ts.dll.

Installing PHP on a Volume Other Than C:

Here are my tips, based on my experiments on this subject:

  • Refer to the online documentation for installing PHP on Windows,
  • Move the C:php directory to the volume of your choice, e.g., E:php
  • Put the php4ts.dll in the same directory as php4apache.dll, e.g., E:phpsapi
  • Edit the Apache config file, httpd.conf:
       LoadModule php4_module E:/php/sapi/php4apache.dll
  • Edit the PHP config file, php.ini, accordingly. For example, if you want to locate the extensions directory and/or your include files on the E: drive, then the paths to them must be specified, e.g.,
       extension_dir = E:phpextensions
       include_path = ".;E:phpinc"
  • Keep the path to php.ini as C:WINNTphp.ini
  • According to a User Contributed Note in the online documentation that I referenced above, when using Windows 2000 Advanced Server you must use forward slashes in php.ini when specifying the path to the PHP extensions directory , e.g.,
       extension_dir = E:/php/extensions

Once you get PHP installed, you can test to see if it is running using one of the simple scripts, such as “Hello World,” or phpinfo(), given in the PHP Introductory Tutorial at

Discuss this article in the ServerWatch discussion forum.

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories