php fastdfs,php添加fastDFS扩展

libfastcommon安装

root@test:~# wget https://github.com/happyfish100/libfastcommon/archive/master.ziproot@test:~# unzip master.ziproot@test:~# cd libfastcommon-masterroot@test:~/libfastcommon-master# ./make.shroot@test:~/libfastcommon-master# ./make.sh install

FastFDS安装

root@test:~# wget https://github.com/happyfish100/fastdfs/archive/master.ziproot@test:~# unzip fastdfs-master.ziproot@test:~# cd fastdfs-master.ziproot@test:~/fastdfs-master# ./make.shroot@test:~/fastdfs-master# ./make.sh install

至此FastFDS已经成功安装到服务器上了,接下来就需要做一些配置

FastDFS配置【如果仅安装php客户端扩展,只需复制和修改client.conf】

root@test:~# cd /etc/fdfs/root@test:/etc/fdfs/#lsroot@test:/etc/fdfs/# cp client.conf.sample client.confroot@test:/etc/fdfs/# cp storage.conf.sample storage.confroot@test:/etc/fdfs/# cp tracker.conf.sample tracker.confroot@test:/etc/fdfs/# find ~/fastdfs-master/ -name http.confroot@test:/etc/fdfs/# cp /root/fastdfs-master/conf/http.conf /etc/fdfs/http.confroot@test:/etc/fdfs/# vim tracker.conf

在tracker.conf中找到

base_path=/home/yuqing/fastdfs...http.server_port=80

改为

base_path=/data/fastdfs...http.server_port=8088

保存退出,如果80端口不被占用可以不做更改 并在根目录下新建data文件夹和data文件夹下的字文件夹fastdfs

root@test:/etc/fdfs/# mkdir /dataroot@test:/etc/fdfs/# mkdir /data/fastdfs

root@test:/etc/fdfs/# vim storage.conf

在storage.conf中找到

base_path=/home/yuqing/fastdfs# tracker_server can ocur more than once, and tracker_server format is# "host:port", host can be hostname or ip addresstracker_server=192.168.1.36:22122# store_path#, based 0, if store_path0 not exists, it's value is base_path# the paths must be existstore_path0=/home/yuqing/fastdfs...http.server_port=80

改为

base_path=/data/fastdfs# tracker_server can ocur more than once, and tracker_server format is# "host:port", host can be hostname or ip addresstracker_server=192.168.1.36:22122# store_path#, based 0, if store_path0 not exists, it's value is base_path# the paths must be existstore_path0=/data/fastdfs...http.server_port=8088

其中tracker_server部分的IP为自己的tracker服务器IP,如果没有改成localhost也是可以的

FastDFS启动

root@test:~# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf startroot@test:~# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

通过ps -ef | grep

fdfs来查看fdfs进程是否存在

root@test:~# ps -ef | grep fdfsroot29731011:16?00:00:00/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf startroot29881011:16?00:00:00/usr/bin/fdfs_storaged /etc/fdfs/storage.conf startroot29932803011:17pts/000:00:00grep fdfs

测试上传

root@test:~# cd /etc/fdfs/root@test:/etc/fdfs/# vim client.conf

在client.conf中找到

base_path=/home/yuqing/fastdfs# tracker_server can ocur more than once, and tracker_server format is# "host:port", host can be hostname or ip addresstracker_server=192.168.0.197:22122...http.tracker_server_port=80...##include http.conf

改为

base_path=/data/fastdfs# tracker_server can ocur more than once, and tracker_server format is# "host:port", host can be hostname or ip addresstracker_server=192.168.0.197:22122...http.tracker_server_port=8088...#include http.conf

这里的端口号http.tracker_server_port=8088一定要和tracker.conf中的端口号一致

root@test:~# echo 'fastDFS_test' >/tmp/test.txtroot@test:~# fdfs_test /etc/fdfs/client.conf upload /tmp/test.txt...example file url: http://xxxxx:8088/group1/M00/00/00/cteDO1cCB1eAFeqeAAAADVt_Kt4115_big.txt

如果出现最下面的URL则说明环境搭建成功

php FastDFS扩展安装

root@test:~#

cd /fastdfs/php_client/

root@test:/fastdfs/php_client/#phpize

Configuring

for:PHP

Api

Version:

20100412

Zend

Module

Api

No:

20100525

Zend

Extension

Api

No:

220100525root

@test:/fastdfs/php_client/#

./configure --with-php-config=/usr/bin/php-config

checking for

grep that

handles long lines and

-e... /bin/grep

... config.status:

creating

config.h config.status:

executing

libtool commands

root@test:/fastdfs/php_client/#

make

Build

complete.

Don`t

forget to run 'make

test'.

root@test:/fastdfs/php_client/#

make install

Installing

shared

extensions:

/usr/lib/php5/20100525/

root@test:/fastdfs/php_client/#

cat /root/fastdfs/php_client/fastdfs_client.ini >>

/etc/php5/fpm/php.ini

至此FastDFS扩展已经安装完成,重启服务器后进行测试

php FastDFS测试验证

root@test:~# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf startroot@test:~# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf startroot@test:~# cp /root/fastdfs/php_client/fastdfs_test.php /usr/share/nginx/www/远端服务器地址/fasrdfs_test.php

如果出现

5.08 fastdfs_tracker_make_all_connections result: 1 array(1) { ["group1"]=> array(12) { ["total_space"]=> int(80632) ... { ["color"]=> string(6) "yellow" ["font"]=> string(4) "Aris" ["size"]=> string(2) "32" } delete file group1/M00/00/00/cteDO1cCjI-ATDFJAAAAD61kmgs438.bin return: 1 bool(true) tracker_close_all_connections result: 1

则表示整个扩展已经安装完成并可以使用了。

常见错误及解决办法

浏览器端测试时出现

5.08 fastdfs_tracker_make_all_connections result: bool(false) bool(false)

重启服务器后未启动storage和tracker服务,解决办法:

root@test:~# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf startroot@test:~# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

安装FastFDS时出现

../common/fdfs_global.c:20:20: fatal error: logger.h: No suchfileordirectory

未安装libfastcommon,解决办法:

root@test:~# wget https://github.com/happyfish100/libfastcommon/archive/master.ziproot@test:~# unzip master.ziproot@test:~# cd libfastcommon-masterroot@test:~/libfastcommon-master# ./make.shroot@test:~/libfastcommon-master# ./make.sh install

测试上传时出现

ERROR -file: ini_file_reader.c,line:394,includefile"http.conf"notexists,line:"#include http.conf"

虽然引入了http.conf文件,但在指定配置目录下并未找到,解决办法:

root@test:/etc/fdfs/#

find ~/fastdfs-master/ -name http.conf/root/fastdfs-master/conf/http.conf

root@test:/etc/fdfs/#

cp /root/fastdfs-master/conf/http.conf

/etc/fdfs/http.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值