You can install Apache and PHP on your own computer, which will make testing and development smoother. The following notes are intended to guide you through the process, although they cannot address details of every setup and system. These notes are written for a Windows installation, but Unix and Mac should not differ too greatly. If you run into trouble, ask the professor or search for information on the Web.
- Download the software: Apache, PHP. For Apache, choose a mirror location and look in the httpd folder. For PHP, choose the VC6 version. The files/versions I downloaded were called httpd-2.2.16-win32-x86-no_ssl.msi and php-5.3.3-Win32-VC6-x86.zip.
- Install. For Apache, run the installer. The book recommends installing at C:/Apache2.2/ instead of the default location; sometimes spaces in the file path can cause trouble. For PHP, simply unpack the zip files and copy them into a directory, again without spaces in the path. The book recommends something like C:/PHP5/. See the book for more recommendations.
- Configure. For Apache, edit httpd.conf in the conf subdirectory. For PHP,
create a copy of php.ini-development called php.ini and edit that.
- Add these lines to httpd.conf to turn on PHP:
LoadModule php5_module C:/PHP5/php5apache2_2.dll AddType application/x-httpd-php .php PHPIniDir "C:\PHP5"
- (Optional) Edit the root web directory and access protections in httpd.conf:
DocumentRoot "C:/Apache2.2/htdocs"
You should see a default something like the above; only files accessible within this folder tree will be served by Apache. The url for this root folder is http://localhost/. You may decide to change the web document root if you like; if you do you should change it here and in the line farther down that looks like <Directory "C:/Apache2.2/htdocs">. The latter line is the beginning of a block of access specifiers that determines under what circumstances the web documents may be served. You may wish to modify these, for example to require a password. Add the following lines just before the closing </Directory> to require a password check:AllowOverride None AuthName "Private login" AuthType Basic AuthUserFile "C:/Apache2.2/conf/.htpasswd" AuthGroupFile /dev/null require user desired-user-name
The file AuthUserFile must be created separately using the command below. (Further details and alternate methods are described here.)C:/Apache2.2/bin/htpasswd -c C:/Apache2.2/conf/.htpasswd desired-user-name
You may change the suggested file location from "C:/Apache2.2/conf/.htpasswd" to something else; just don't put it inside the web document tree as this would be insecure. - Set the extensions directory in php.ini to the correct path based on where you installed the PHP files. For example:
extension_dir = "C:/PHP5/ext"
- Add or uncomment these lines in php.ini:
extension=php_pdo.dll extension=php_pdo_sqlite.dll extension=php_sqlite.dll extension=php_sqlite3.dll
- Add these lines to httpd.conf to turn on PHP: