|CPSC 343||Database Theory and Practice||Fall 2017|
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.
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 should have a directory called www in your home directory. Within www, create a directory called cs343.
You must use exactly the names indicated (and with the same case).
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
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.
The examples used in the other Quick Start documents are available for you to try out. The URL:
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:
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.
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 firstname.lastname@example.org
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.