php安装FastDFS客户端拓展

php安装FastDFS客户端拓展

CentOS下的php环境安装FastDFS客户端比较麻烦,这里为各位小伙伴提供一篇参考

使用环境

CentOS 7
PHP 7.3
FastDFS 5.08

下载FastDFS相关资源依赖

打开github源码库
下载地址
https://github.com/happyfish100/libfastcommon

下载libfastcommon-master.zip到服务,解压zip包

unzip libfastcommon-master.zip

编辑

cd libfastcommon-master
./make.sh
./make.sh install

注意该依赖很重要,不安装的话,后面的可能无法进行

下载FastDFS到CentOS服务器下

下载地址
https://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/
github库下载地址
https://github.com/happyfish100/fastdfs
这里下载的是FastDFSV5.08
php安装FastDFS客户端拓展
解压压缩包

tar -zvxf FastDFS_v5.08.tar.gz

直接安装php_client端

cd ./FastDFS/php_client
/www/server/php/73/bin/phpize  #对应要编译版本的phpize
./configure --with-php-config=/www/server/php/73/bin/php-config #php安装目录下的php-config
make && make install

报错

/root/FastDFS/php_client/fastdfs_client.c:10:33: fatal error: fastdfs/fdfs_client.h: No such file or directory
 #include "fastdfs/fdfs_client.h"

直接安装php_client端是不行的,必须整个FastDFS都安装一次,不友好

编译并安装FastDFS

cd ./FastDFS
./make.sh && ./make.sh install

必须先安装成功FastDFS,方才可以安装php_client端

再次执行php_clinet安装

cd ./FastDFS/php_client
/www/server/php/73/bin/phpize  #对应要编译版本的phpize
./configure --with-php-config=/www/server/php/73/bin/php-config #php安装目录下的php-config
make && make install
...
...
Installing shared extensions:     /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/

安装成功

首先检查一下php的拓展

/www/server/php/73/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib

配置php.ini

#修改php.ini文件添加fastdfs相关配置(php_client文件夹下fastdfs_client.ini内容添加到php.ini中)
cat ./fastdfs_client.ini >> /www/server/php/73/etc/php.ini
#重启php
service php-fpm restart 
#验证,查看是否有fastdfs_client扩展
/www/server/php/73/bin/php -m
# 报错
[2022-01-19 15:00:03] ERROR - file: shared_func.c, line: 1214, file /etc/fdfs/client.conf not exist
[2022-01-19 15:00:03] ERROR - file: client_func.c, line: 198, load conf file "/etc/fdfs/client.conf" fail, ret code: 2
PHP Fatal error:  Unable to start fastdfs_client module in Unknown on line 0

说找不到client.conf配置文件,无法启动fastdfs_client模块,估计是php.ini配置中的路径问题

vi /www/server/php/73/etc/php.ini
# 修改client.conf配置的地址
fastdfs_client.tracker_group0 = /etc/fdfs/client.conf # 这里修改正确的路径,可以直接指向安装包下的FastDFS/conf/client.conf

最后一部,修改clien.conf的tracker_server主机地址配置

#client.conf
tracker_server=192.168.0.197:22122

重启php

service php-fpm restart 
# 查看一下是否启动成功
[root@hecs-x-large-2-linux-20201101153549 FastDFS]# /www/server/php/73/bin/php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fastdfs_client
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib

[Zend Modules]

启动成功

php 客户端的相关封装包
https://sourceforge.net/projects/fastdfs/files/PHP%20Client%20API%20Source%20Code/

上一篇:文档型数据库-1-[MongoDB]在windows中的安装及python操作


下一篇:Mybatis 源码-04.SQL 语句构建器