Created
August 10, 2017 21:50
-
-
Save ajbm6/fd3877d80d46f898409631fc5f705cdb to your computer and use it in GitHub Desktop.
Webserver and PHP configuration tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Webserver and PHP configuration tester | |
* | |
* @author odan | |
* @license MIT | |
*/ | |
if (!isset($_SESSION)) { | |
session_name('phptest'); | |
session_start(); | |
} | |
write("Time: " . date('Y-m-d H:i:s')); | |
write("Host: " . $_SERVER['HTTP_HOST']); | |
write(''); | |
$arrModules = apache_get_modules(); | |
//var_dump($arrModules); | |
$boolValue = in_array('mod_rewrite', $arrModules); | |
if ($boolValue) { | |
write("Apache - mod_rewrite module is installed: OK"); | |
} else { | |
write("Apache - mod_rewrite module is not installed: please enable mod_rewrite"); | |
} | |
$boolValue = isset($_SERVER["HTTP_MOD_REWRITE"]); | |
if ($boolValue) { | |
write("Apache - RewriteCond in .htaccess is working: OK"); | |
} else { | |
write("Apache - RewriteCond is not working: ERROR"); | |
} | |
if (version_compare(PHP_VERSION, '5.4.0') >= 0) { | |
write("PHP Version = " . PHP_VERSION . ": OK"); | |
} else { | |
write("PHP Version = " . PHP_VERSION . ": Too old"); | |
} | |
// | |
// memory_limit: 512 MB | |
$strValue = ini_get('memory_limit'); | |
if ((int) $strValue >= '512') { | |
write("php.ini - memory_limit = $strValue: OK"); | |
} else { | |
write("php.ini - memory_limit = $strValue: Not enough memory (min. 512M)"); | |
} | |
// post_max_size: 8 MB | |
$strValue = ini_get('post_max_size'); | |
if ((int) $strValue >= '8') { | |
write("php.ini - post_max_size = $strValue: OK"); | |
} else { | |
write("php.ini - post_max_size = $strValue: Not enough (min. 8M)"); | |
} | |
// upload_max_filesize: 15 MB | |
$strValue = ini_get('upload_max_filesize'); | |
if ((int) $strValue >= '15') { | |
write("php.ini - upload_max_filesize = $strValue: OK"); | |
} else { | |
write("php.ini - upload_max_filesize = $strValue: Not enough (min. 15M)"); | |
} | |
// date.timezone = Europe/Zurich | |
$strValue = date_default_timezone_get(); | |
if ($strValue == 'Europe/Zurich') { | |
write("php.ini - Default timezone = $strValue: OK"); | |
} else { | |
write("php.ini - Default timezone = $strValue: Invalid (Must be: Europe/Zurich)"); | |
} | |
// check extensions | |
$boolValue = extension_loaded('suhosin'); | |
if (!$boolValue) { | |
write("php.ini - suhosin is not installed: OK"); | |
} else { | |
write("php.ini - suhosin is installed: please remove suhosin"); | |
} | |
// session check | |
if (!isset($_SESSION['counter'])) { | |
$_SESSION['counter'] = 0; | |
} | |
$_SESSION['counter'] ++; | |
if ($_SESSION['counter'] > 0) { | |
write("Session: OK"); | |
} else { | |
write("Session not correct installed"); | |
} | |
phpinfo(); | |
function write($str) | |
{ | |
echo $str . "<br>\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment