workerman 学习记录
作者:互联网
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 "\033[32;40m [OK] \033[0m\n"; } else { return "\033[31;40m [fail] \033[0m\n"; } } 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 "\n\033[31;40mFunction $func may be disabled. Please check disable_functions in php.ini\n"; echo "see http://doc.workerman.net/faq/disable-function-check.html\033[0m\n"; exit; } }
脚本如果全部显示ok,则代表满足WorkerMan要求
如果不是全部ok,则参考下面文档安装缺失的扩展即可。
(注意:检测脚本中没有检测event扩展或者libevent扩展,如果业务并发连接数大于1024必须安装event扩展或者libevent扩展,并且优化Linux内核
标签:记录,workerman,学习,disable,posix,func,033,pcntl,check 来源: https://www.cnblogs.com/cshaptx4869/p/13930168.html