当前使用Centos7.x系统,php使用7.4版本,wlnmp一键包已支持该扩展
注:CentOS6.x的话需要升级autoconf版本
smbclient扩展包地址:https://pecl.php.net/package/smbclient
1、安装所需依赖,如果在编译时还提示缺少其他依赖,请自行安装
yum install autoconf gcc gcc-c++ libsmbclient-devel
|---|-----------------------------------------------------| | 1 | yum install autoconf gcc gcc-c++ libsmbclient-devel |
2、下载smbclient最新稳定版
wget https://pecl.php.net/get/smbclient-1.0.0.tgz tar xf smbclient-1.0.0.tgz cd smbclient-1.0.0 /usr/local/php/bin/phpize
|---------|---------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 | wget https://pecl.php.net/get/smbclient-1.0.0.tgz tar xf smbclient-1.0.0.tgz cd smbclient-1.0.0 /usr/local/php/bin/phpize |
根据自己phpize的位置来运行即可(不知道phpize在哪的直接find / -name phpize查找),运行完提示下面信息,然后编译
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
3、编译扩展模块
./configure --with-php-config=/usr/local/php/bin/php-config make make install
|-------|-------------------------------------------------------------------------------| | 1 2 3 | ./configure --with-php-config=/usr/local/php/bin/php-config make make install |
执行完成后会显示扩展模块编译到的目录/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
4、修改php.ini添加扩展
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/" extension=smbclient.so
|-----|-------------------------------------------------------------------------------------------------------| | 1 2 | extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/" extension=smbclient.so |
注意:如果之前配置过extension_dir路径了,则只需要配置extension=smbclient.so即可
保存退出,重启php