PHP cant find SNMP modules under Windows 7

本秂侑毒 提交于 2019-11-29 08:51:25

The PHP docs is misleading for Windows; In order to get rid of the errors and have SNMP module working properly, you MUST add an environment variable in the System, called MIBDIRS and pointing to the location of your mib files.

On Windows 7 for example, that would be System Properties > Environment Variables > User variables section, click New and add MIBDIRS, with value of C:\usr\mibs (or wherever you put the mibs folder).

The files should be extracted using a Net-SNMP package, tested with version net-snmp-5.7.2.1 on PHP 5.4.7 using CLI mode.

Acording to PHP SNMP Instllation page:

The Windows distribution of Net-SNMP contains support files for SNMP in the mibs directory. This directory should be moved to DRIVE:\usr\mibs, where DRIVE must be replaced with the driveletter where PHP is installed on, e.g.c:\usr\mibs. Alternatively you may set MIBDIRS environment variable pointed to your MIBs folder.

http://php.net/manual/en/snmp.installation.php

Copied from another post:

Apparently there are 2 environment variables you can set. One is MIBDIRS which is where all the MIB files are. Another is MIBS, which I believe is which SNMP modules you want to load. By setting MIBS to ALL, I was able to get rid of the errors

The php package doesn't include mibs folder, what you have to do is download the source file of net-snmp and copy the folder into your php directory

download link https://sourceforge.net/projects/net-snmp/files/net-snmp/5.7.3/

after that, unzip the zip file and copy the mibs folder to your php directory

for exmaple,copy it to C:\PHP\Extras\mibs Thne add a new system variable called MIBDIRS. Its value should be: C:\PHP\Extras\mibs

Finally, you can run php -m

and you issue will be resoved

I attach a screenshot for your reference.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!