Debug apache log files from php

FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Debug apache log files from php

This is a secure method to debug your apache from within php

For debugging without checking error_log/access_log files

  1. create a file called phpinfo.php in your / directory
  2. the contents of phpinfo.php

    <?php phpinfo(); ?>
    
  3. Use this for your .htaccess file.

    Options +FollowSymLinks
    ErrorDocument 404 /phpinfo.php
    

Now instead of getting a 404 error you will see debug information which will help you find out what the problem is.

Add security to phpinfo.php

Cd-MaN pointed out a security problem this method has, it reveals sensitive info to anyone who requests phpinfo.php.

Also, you better use it only as a temporary measure, because it reveals many sensitive information about your server (eg. delete it after you done debugging)

Here is a fix for this.

Secure phpinfo.php with .htaccess

This only allows the user from IP address 2.3.65.6, everyone else is redirected to http://www.domain.com

ErrorDocument 403 http://www.domain.com
Order deny,allow
Deny from all
Allow from 2.3.65.6

Secure phpinfo.php with php

Same thing only uses .htaccess. Change your phpinfo.php file to the following

<?php
 ob_start();
 phpinfo();
 $debugger = ob_get_clean();
 if ($_SERVER['REMOTE_ADDR'] == '2.3.65.6')  echo $debugger;
?>

«
»

Skip to Comments

Add Your Opinion

Reader Comments

  1. Cd-MaN ~

    The documentation for phpinfo can be found here: http://www.php.net/phpinfo

    Also, you better use it only as a temporary measure, because it reveals many sensitive information about your server (eg. delete it after you done debugging)


It's very simple - you read the protocol and write the code. -Bill Joy

HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C | TLDP | WAI | DISA | ICSI | GIAC | SANS RR | GHOST | DEFCON | NIST | DHS CYBER | NIST | .:: Phrack Magazine ::.

↑ TOPExcept where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. HTTPD based on NCSA HTTPd

Site Map | Contact Webmaster | Email AskApache | Glossary | License and Disclaimer | Terms of Service