File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 11<?php
2+ error_reporting (E_ALL );
3+ ini_set ('display_errors ' , 1 );
24
35echo '<h1 style="text-align: center;">欢迎使用DNMP!</h1> ' ;
46echo '<h2>版本信息</h2> ' ;
810echo '<li>Nginx版本: ' , $ _SERVER ['SERVER_SOFTWARE ' ], '</li> ' ;
911echo '<li>MySQL服务器版本: ' , getMysqlVersion (), '</li> ' ;
1012echo '<li>Redis服务器版本: ' , getRedisVersion (), '</li> ' ;
13+ echo '<li>MongoDB服务器版本: ' , getMongoVersion (), '</li> ' ;
1114echo '</ul> ' ;
1215
1316echo '<h2>已安装扩展</h2> ' ;
@@ -53,6 +56,27 @@ function getRedisVersion()
5356 }
5457}
5558
59+ /**
60+ * 获取MongoDB版本
61+ */
62+ function getMongoVersion ()
63+ {
64+ if (extension_loaded ('mongodb ' )) {
65+ try {
66+ $ manager = new MongoDB \Driver \Manager ('mongodb://root:123456@mongodb:27017 ' );
67+ $ command = new MongoDB \Driver \Command (array ('serverStatus ' =>true ));
68+
69+ $ cursor = $ manager ->executeCommand ('admin ' , $ command );
70+
71+ return $ cursor ->toArray ()[0 ]->version ;
72+ } catch (Exception $ e ) {
73+ return $ e ->getMessage ();
74+ }
75+ } else {
76+ return 'MongoDB 扩展未安装 × ' ;
77+ }
78+ }
79+
5680/**
5781 * 获取已安装扩展列表
5882 */
You can’t perform that action at this time.
0 commit comments