February 28, 2021
Hot Topics:

Learning PHP: Installing and Configuring

  • By Elizabeth Fulghum
  • Send Email »
  • More Articles »

Configuring the PHP.INI

The second file you need to edit is the php.ini, which contains all the settings to control how the PHP processor works. The php zip file contains two sample configuration files, php.ini-dist and php.ini-optimized, but we will be working with the first. There are several changes that need to made in this file:

Find the line that reads:

extension_dir = ./

and change it to:

extension_dir = ./extensions

This is a relative path to the directory which contains extensions to php. Extensions allow you to plug-in additional functions.

Find the line that reads:

;upload_tmp_dir =

and change it to:

upload_tmp_dir =./uploadtemp

This is the directory that will hold any temporary files created when uploading files with PHP. You will also notice an option right below it:

"upload_max_filesize = 2M"

that controls the maximum allowed file size for uploaded files, in megabytes. You can adjust this setting if you feel the need.

Next, look for a list of dlls commented out with ";". Commenting or un-commenting a dll will determine whether an extension is loaded when PHP is started. For the purposes of these tutorials, you should uncomment at least the following dlls:

  • php_gd.dll
  • php_mcrypt.dll
  • php_pdf.dll
  • php_domxml.dll

In the section titled "Module Settings", there are several settings that control how mail is handled. First, you will see a section that looks like this:

[mail function]
; For Win32 only.

A SMTP server is required for sending mail within PHP documents. You have the option of installing a mail server and using that, however the easiest solution is to use an existing SMTP server. If you have a POP3 mail account, you can use the same out-going mail server that you use for sending email. You should also enter your email address in the line that reads: "sendmail_from =."

Finally, scroll down to the section labeled "Session" and change the following:

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored.
session.save_path =


; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored.
session.save_path = . /sessiontemp

After you have made the changes, save the file as PHP.ini and move it to your Windows directory. If you are on Windows NT, or 2k, this would be C:\winnt\. If you are Windows 95-ME or XP, you would move it to C:\windows\.

(View a sample configured PHP.ini file - from PHP vs. 4.06)

Testing the Installation

If everything was configured correctly, Apache and PHP should be working. To test it, create a text file with the following contents:

<?php phpinfo(); ?>

and save it as test.php in your C:\apache\htdocs\ directory. The file is a simple script that calls a function which displays information about your php configuration.

Use the "Start Apache Server in Console" icon on your menu to start Apache. If you see something like "Apache/1.3.20 <Win32> PHP/4.0.6 running" in the window that pops up, it is a good bet that the installation was a success. To make sure, open up a browser and enter the URL http://localhost/test.php.

If you are not familiar with web servers, you are probably wondering why http://localhost/ resolved to your computer. The short, non-technical explanation is that localhost is a reserved name that always points to your computer. The IP address also works the same way. Since these are internal addresses, if you want someone to be able to view your pages over the web, you need to use your actual IP address or host name.

Also keep in mind that C:\apache\htdocs\ is your root directory. If you want to test a page through the server, or make it accessible, it should go in this directory, or in a sub-directory of it.

Setting up Mysql

Now that Apache and PHP are set up, the final step is to install Mysql. Before you begin, be sure you have shut down Apache. Once you have, unzip and run the setup file for Mysql. The suggested installation location is C:\apache\mysql.

The latest version of Mysql includes a Windows GUI to administer the server and databases called WinMySQLAdmin. To start it up, run C:\apache\mysql\bin\winmysqladmin.exe. Because it is your first time running it, the program will ask you for a username and password. This username/password combination will be used to any time you need to connect to the server.

After you enter the information, the control panel icon will appear in your system tray with a red traffic light. Double click on the icon, and click the tab that says "my.ini Setup", choose which version of Mysql you would like to run, and save the modifications.

To start Mysql, right click on the traffic light in the left-hand corner, choose your operating system, and start the service.

Notes for Installation on IIS (version 4+)

Another popular web server choice for Windows is IIS. While the bulk of this article has focused on the installation of PHP with Apache, you will find some additional notes on IIS here. Much of the configuration process is the same, and there are no changes to the installation of Mysql. The install.txt packaged with PHP itself also includes additional information on installing PHP with IIS and other web servers.

If you are running IIS, you can download the version of PHP that includes the installer, which will install PHP and automatically configure IIS to work with it. However, if you would prefer to set up PHP manually, the installation is fairly easy.

After unzipping PHP to a directory on your computer like C:\php\, follow the same instructions for creating additional directories and copying files as detailed above for PHP configuration with Apache. You should also edit your PHP.ini in the same way, and save the file to your Windows directory.

With IIS, you have the choice of running PHP as a CGI, or as an ISAPI module. Like the Apache module, the ISAPI module is still relatively new, and can sometimes be even more unstable than the Apache module. For this reason, it is recommended that you choose the CGI version.

To complete the installation of the CGI version, start the IIS administrative console, right click on the Default Web Site, and choose Properties. Navigate to the "Home Directory" tab, and click the "Configuration" button. At this point you should see a listing of file extensions and associated handlers.

Next, click "Add". Where it asks for an Executable, enter in the path to PHP (c:\php\php.exe, for example) and enter .php as the Extension. Click okay until you have closed the Properties window and then restart the server.

After testing to be sure the install was successful, you can proceed to installing Mysql.


Hopefully, your installations of Apache, PHP and Mysql have been successful. If you have encountered errors during your installation, make sure that you have remembered to copy the php dll file to your system directory, and that you have a PHP.ini in your Windows directory. While relatively minor, these are two of the most common installation problems.

Next time, we will jump into learning the language with an introduction to the basic structure and elements of PHP.

Liz Fulghum currently lives in Annapolis, MD where she works as a web designer for a custom shirt retailer. Liz was convinced to try PHP as an alternative to Perl; she has been a fan ever since and frequently works as a freelance developer.

# # #

Page 2 of 2

This article was originally published on October 29, 2001

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date