60
886
Appendix A Installing PHP and MySQL
Adding PHP to Your Apache Configuration
You may need to edit one of Apache’s configuration files.Open the
httpd.conf
file in
your favorite editor.This file is typically located in the
c:\Program Files\Apache
Group\Apache\conf\
directory.Look for the following lines:
LoadModule php5_module c:/php/php5apache.dll
AddModule mod_php5.c
AddType application/x-httpd-php .php
Action application/x-httpd-php “/php/php.exe“
If you don’t see these lines,add them to the file,save it,and restart your Apache server.
Adding PHP and MySQL to Microsoft IIS and PWS
This section covers how to add PHP and MySQL support to IIS with the ISAPI
(
php5isapi.dll
) module. (You can also install it as a CGI,but we strongly recommend
you use the ISAPI module because it is faster.) This section assumes that you have fol-
lowed the steps in the preceding sections.The main difference is that the
doc_root
con-
figuration directive is likely to be
c:/Inetpub/wwwroot
.
Next, you need to open Internet Information Services.If you have Windows 2000 or
XP,you can find it in the Control Panel under Administrative Tools.If you don’t see this
option,you may need to install IIS from your original Windows CDs before continuing.
When IIS is open,you should see a tree view of services on the left side.Right-click
the web server (usually called Default Web Server) and select Properties.
The resulting Properties dialog box contains quite a lot of information,but you need
to change only a few things.Under Home Directory,click the Configuration button.
Under Application Mappings,select Add to add PHP.You must then supply an exe-
cutable.Supply the full path to the location of
php5isapi.dll
(probably
c:\php\php5isapi.dll
). In the Extension box,you should type
.php
.You also need to
check the Script Engine box if it isn’t already checked.Click OK.
If you want to be able to do HTTP Authentication (which we cover in this book),
you should also look under ISAPI Filters. Select Add.You need to supply a filter name
(in this case,type
PHP
) and an executable (here,supply the full path to the
php5isapi.dll
file as just shown).Click OK.Finally,close the Properties dialog box by
clicking Apply.
You should now stop the web server (or check that it is stopped) and then restart it.
You can do this from the Internet Information Services window by right-clicking on
the web server and choosing Stop.You can restart in the same way by selecting Start.
Testing Your Work
The next step is to start your web server and test to ensure that you have PHP working.
Create a
test.php
file and add the following line to it:
<? phpinfo(); ?>