University Computing Systems
Debugging Your Code
1. The URL :
http://sunlabN.njit.edu/~<ucid>/...
where N = 31,32,33,34,35
can be used as an aid to debugging your code.
The Apache Web server log files access_log and error_log
corresponding to the above URL are located in /export/apache/logs
on afs31.njit.edu - afs35.njit.edu. Search through these log files
to help debug your code.
The Apache-PHP running on the sunlabN listed above is the same as that running
on web.njit.edu.
The URLs listed above are accessible only from within the NJIT network - i.e., from on the NJIT campus, or via VPN.
Note: For security reasons, errors that occur during the execution
of PHP code are not displayed as a part of the output. As a
workaround, see Alternate Method below.
Example of Using Log Files
Assuming that that your UCID is "abc123",
and your program is "homework4.php",
and you're using afs5.njit.edu to debug it.
- When you log in, the file is "public_html/homework4.php"
aka "/afs/cad/a/b/abc123/public_html/homework4.php".
- The ULR will be "http://afs5.njit.edu/~abc123/homework4.php"
- You could find error messages on afs5.njit.edu with these commands:
- cd /export/apache/logs
- grep abc123/public_html/homework4.php access_log error_log
- The last message displayed would be from your last attempt to use the
script.
Alternate Method
Some types of syntax errors can be easily found just by running a
a test of your PHP script right on the system command line with the
"php" (/usr/local/bin/php) command. For the example given above, it
would work like this:
- cd $HOME/public_html
- php homework4.php
This would display the same error message as given in the example.
However if your script has no errors, all the HTML generated by the
script will be displayed on your screen, and you might get prompted for
input variables. Press CTRL-C to exit php, and use the earlier
technique for additional debugging.
2. Users are entirely responsible for their code.