Linux系统环境检测
Linux系统可以使用以下脚本测试本机PHP环境是否满足WorkerMan运行要求。
curl -Ss http://www.workerman.net/check.php | php
check.php
<?php $version_ok = $pcntl_loaded = $posix_loaded = false; if (version_compare(phpversion(), "5.3.3", ">=")) { $version_ok = true; } if (in_array("pcntl", get_loaded_extensions())) { $pcntl_loaded = true; } if (in_array("posix", get_loaded_extensions())) { $posix_loaded = true; } function check($val) { if ($val) { return " 33[32;40m [OK] 33[0m "; } else { return " 33[31;40m [fail] 33[0m "; } } echo "PHP Version >= 5.3.3 " . check($version_ok); echo "Extension pcntl check " . check($pcntl_loaded); echo "Extension posix check " . check($posix_loaded); $check_func_map = array( "stream_socket_server", "stream_socket_client", "pcntl_signal_dispatch", "pcntl_signal", "pcntl_alarm", "pcntl_fork", "posix_getuid", "posix_getpwuid", "posix_kill", "posix_setsid", "posix_getpid", "posix_getpwnam", "posix_getgrnam", "posix_getgid", "posix_setgid", "posix_initgroups", "posix_setuid", "posix_isatty", ); // 获取php.ini中设置的禁用函数 if ($disable_func_string = ini_get("disable_functions")) { $disable_func_map = array_flip(explode(",", $disable_func_string)); } // 遍历查看是否有禁用的函数 foreach ($check_func_map as $func) { if (isset($disable_func_map[$func])) { echo " 33[31;40mFunction $func may be disabled. Please check disable_functions in php.ini "; echo "see http://doc.workerman.net/faq/disable-function-check.html 33[0m "; exit; } }
脚本如果全部显示ok,则代表满足WorkerMan要求
如果不是全部ok,则参考下面文档安装缺失的扩展即可。(注意:检测脚本中没有检测event扩展或者libevent扩展,如果业务并发连接数大于1024必须安装event扩展或者libevent扩展,并且优化Linux内核
linux特殊含义的转义符 33
格式: echo -e "