安装

重要提示:为了使用 UCD SNMP 包,需要在编译之前将 NO_ZEROLENGTH_COMMUNITY 定义为 1。 在配置 UCD SNMP 之后,编辑 config.hacconfig.h,查找 NO_ZEROLENGTH_COMMUNITY,将 #define 所在行的注释去掉。修改后应该类似这样:

#define NO_ZEROLENGTH_COMMUNITY 1
然后使用 --with-snmp[=DIR] 选项编译 PHP。

如果在组合 SNMP 命令时看到奇怪的字段错误,那就是因为没有遵从上述说明。如果不想重新编译 UCD SNMP,可以使用 --enable-ucd-snmp-hack 开关编译 PHP 以绕开上述错误。

Windows 版本在目录 mibs 中包含了支持 SNMP 的文件。此目录应该移到 DRIVE:\usr\mibs,其中 DRIVE 是安装 PHP 所在的盘符,例如 c:\usr\mibs

User Contributed Notes

robinson 17-Nov-2016 01:43
There is no "mibs" directory in the php package, I check with 5.2,5.4,5.5 and 5.6, none of them has the net-snmp mibs folder.

What you have to do is download the source of net-snmap and copy the folder into your unpacked php folder besides the instructions provided above

net-snmap download link

https://sourceforge.net/projects/net-snmp/files/net-snmp/

after you download, unzip the file and copy folder mibs to your php folder
bug404 at free dot fr 08-Sep-2014 02:00
If net-snmp was not installed in default c:\usr folder (which may be the case for most peoples used to Windows instead of Linux), then, you should also create SNMP_PERSISTENT_DIR system environment variable with "persistent" folder location (located in snmp folder).
Otherwise, php will will create its own persistant folder in c:/usr/snmp/persistent folder, which is probably not what you want !
Coffee-fan 14-Feb-2013 02:35
In order to build and install php in Ubuntu 12.10, beyond the normal "build-essential" package, I had to install the following packages: apache2-prefork-dev  libxml2-dev libsnmp libsnmp-dev libtool

Command line should be like this:

sudo apt-get install apache2-prefork-dev libxml2-dev libsnmp libsnmp-dev libtool
Darren Wolfe 04-Jun-2012 10:18
If PHP complains that some mibs are missing and they are not included in your windows php package, they can be obtained from the source package of net-snmp itself.
flintjt att hotmail dot com 04-Apr-2011 11:23
For win32 (tested on win XP and 2k3 server 32bit):
Tested with versions 5.3.3 VC9, and 5.3.6 VC9.
The php_snmp.dll, requires that you set the environment variable MIBDIRS pointed to your MIBs folder.