CPSC 343 Database Theory and Practice Fall 2017

HTML/PHP Local Quick Start

This document is intended to describe the local environment for working with HTML and PHP in CPSC 343. Refer to the PHP Quick Start for information on the PHP language, the PHP Web Quick Start for information on getting information about the web server environment, processing HTML forms, and working with sessions and cookies, or the PHP MySQL Quick Start for information on interacting with MySQL from PHP.


Contents


Setup

Your HTML and PHP files will need to be web-accessible so they can be run. The webserver has been configured to look for your files in a very specific place. To set this up:

You must use exactly the names indicated (and with the same case).


Naming and Viewing Your HTML and PHP Files

All of the PHP and HTML files that you create should go within your www/cs343 directory (or a subdirectory of that directory). Files containing PHP code must have a filename ending with .php; files containing only HTML code must have a filename ending with .html (or .php, but there's no reason to make the PHP processor handle a file without any PHP).

You can browse a listing of the files in your www/cs343 directory with the URL

  http://172.21.7.83/cs343f17/username

where username is replaced by your Linux username.

You can go directly to a file by giving its URL e.g. http://172.21.7.83/cs343f17/fprefect/datetime.php is the URL for a file called datetime.php in fprefect's www/cs343 directory, and http://172.21.7.83/cs343f17/fprefect/ex1/datetime.php would refer to a file called datetime.php in fprefect's www/cs343/ex1 directory.


Viewing the Quick Start Examples

The examples used in the other Quick Start documents are available for you to try out. The URL:

  http://172.21.7.83/cs343f17/quickstart

Viewing the PHP Error Log

Because the PHP is processed by the webserver, PHP syntax errors and other problems which prevent PHP from executing are logged on the server. Normally this messages go to the webserver's error log (which is not available to regular users), but to help your debugging, I have redirected PHP errors to a web-accessible file:

  http://172.21.7.83/cs343f17/php_errors.txt

All PHP errors are logged to this file, so it will contain much more than just your current error. However, the most recent additions are at the end and the error messages include the filename where the error occurred - use this to help you locate the relevant information. Don't forget to reload the page in order to see the most recent version of the log.

Note: to keep the file size from growing out of control, the log is periodically rotated. php_errors.txt.1, php_errors.txt.2, etc contain older versions.


Remote Access

If you are not on the campus network, you will either need to run VPN (information) or use port forwarding (which requires ssh). For port forwarding, run the following on your local machine:

  ssh -CNL 9001:172.21.7.83:80 username@math.hws.edu

Replace username with your CS department username, and enter your CS department password when prompted for a password. This command takes traffic sent to port 9001 on your local machine, sends it over the ssh connection to math.hws.edu, and tells math.hws.edu to then forward it to port 80 (the webserver port) on 172.21.7.83. You can change 9001 to something else if you want - it's just a port that is probably not being used by something else. Now when you want to access a URL involving 172.21.7.83, replace it with localhost:9001 instead e.g.

  http://localhost:9001/cs343f17/quickstart/

Valid HTML 4.01!