Specifications

PHP accomplishes this by doing the following:
PHP refuses to interpret the command-line arguments, when invoked as a CGI binary.
PHP also prevents access to any Web documents without checking permission and
access when invoked as a CGI binary. However, you must enable
--enable-force-cgi-redirect and set up the runtime configuration directives
doc_root and user_dir.
Of course, this is only relevant if you choose the default setup.
If you choose to use the CGI method, an even more secure option is to put the PHP binary
somewhere outside the Web tree. The typical location used would be the /usr/local/bin direc-
tory for UNIX and c:\PHP-DIR\ for Windows. The downside to this option is that you will have
to include a line to execute the PHP interpreter in all CGI scripts. For example, on a UNIX
machine with the PHP interpreter at /usr/local/bin/php, the first line of each script would be
#! /usr/local/bin/php
You will also need to set any file permissions to make each script executable. That is, you will
need to treat the PHP script as you would treat a CGI script written in Perl.
In this appendix we will primarily cover the module option as the method to run PHP in a
UNIX environment, and the CGI method with Windows systems.
Installing Apache, PHP, and MySQL Under UNIX
Lets begin by installing Apache, PHP, and MySQL under a UNIX environment. First, we must
decide what extra modules we will load under the trio. Because some of the examples covered
in this book entail using a secure server for Web transactions, we will install the Secure Socket
Layer (SSL) enabled server. Our PHP setup will be the default setup but will also cover
enabling the following libraries under PHP.
http://curl.haxx.se/: Client URL Library functions
http://pspell.sourceforge.net/: Portable Spell Checker Libraries
http://www.pdflib.com/pdflib/index.html: Library for Generating PDF documents
on-the-fly
These are just three of the many libraries available for PHP. We are enabling them so you can
get an idea of what it takes to enable extra libraries with PHP. It is recommended that you
install all libraries on your machine before you compile the PHP module.
We have already discussed the download and installation of these library programs in the rele-
vant chapters, so this is not covered here. What will be covered is how you enable them under
PHP during the compilation process.
Installing PHP 4 and MySQL
A
PPENDIX A
A
INSTALLING PHP 4
AND MYSQL
783
38 7842 app a 3/6/01 3:40 PM Page 783