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 http://www.php.net/downloads.php. If you are interested in development versions of the next Windows release, go to http://snaps.php.net/win32/. If you are looking for past release builds for Windows go to http://ftp.proventum.net/pub/php/win32/. Online documentation for installation on Windows, with user comments, is available at http://www.php.net/manual/en/install.windows.php. 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: http://www.php.net/manual/en/install.apache.php. Documentation for offline use can be downloaded from http://www.php.net/download-docs.php. A good way to keep up with PHP developments is to read the PHP Weekly Summary at http://www.zend.com/zend/week/.
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,
php-4.2.2-Win32.zip. 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). Like the Apache folder, put it at the root of the
C: drive. Thus, the path to the folder is
Then, copy the file
C:WINNTsystem32. Also, copy the
mibs folder from
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 file must be located in the
The following are the significant changes that I made to
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:
On to help with development. For production sites, it is recommended for security reasons that this be set to
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
- Web Database Applications, Appendix D
- Programming PHP, Chapter 7
- Professional PHP4, Chapter 8
- Session Tracking: Part 2
For a basic explanation on using
include files see http://hotwired.lycos.com/webmonkey/99/21/index4a.html. I put my
include files (
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,
I used a directive,
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:
Installing PHP on a Volume Other Than
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 http://www.php.net/tut.php
Discuss this article in the ServerWatch discussion forum.