The Apache Error Log
If you have CGI programs that do not work as expected or you receive an internal server error, you should have a look at the Apache error log to see details of the error. The error log is located in /var/log/apache2/error.log. You can edit it using nano or just scan through it with cat.
sudo nano /var/log/apache2/error.log
sudo cat /var/log/apache2/error.log | less