Skip to content

How to prevent PHP script from running in Apache

How to prevent PHP script from running in Apache

Answer:

If you have a PHP script and want it run under in command line only, not in the web server context, you can use the following method.

<?php

if ( php_sapi_name() != "cli" ) {
    print "This script must be run from the command line\n";
    exit();
}
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  1. Prevent go way SSH session killing still running job
  2. Apache restart explained
  3. Disable sending PHP version information by Apache/mod_php
  4. How to restart Apache without disconnecting user
  5. How to perform syntax check on a bash script?

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*