FastDFS-5.05 tracker服务器安装nginx+php+上传测试

1.接上一篇,fastdfs安装好nginx,安装php程序,供开发上传及调用,安装fdfs php模块,前提是安装好PHP

cd /usr/local/src/FastDFS/php_client/
/usr/local/php/bin/phpize 
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
ll /usr/local/php-5.6.20/lib/php/extensions/no-debug-non-zts-20131226/
cp /usr/local/src/php-5.6.20/php.ini-production /usr/local/php/lib/phh.ini

 2. 把fdfs文件追加到php文件中

cd /usr/local/src/FastDFS/php_client/
vim fastdfs_client.ini
cat fastdfs_client.ini >> /usr/local/php/lib/php.ini

 3.检查fastdfs 里的php是否正常

[root@img01 fdfs]# /usr/local/php/bin/php /usr/local/src/FastDFS/php_client/fastdfs_test.php 
5.05
fastdfs_tracker_make_all_connections result: 1
array(1) {
  ["G1"]=>
    int(0)
file exist: 1
token=f6aeb826add3678e438582ca65683443
file content: thisisatest.(15)
storage_download_file_to_file1 result: 1
storage_set_metadata1 result: 1
string(53) "G1/M00/00/00/rBABKVe8AKKAJpMZAAAAD61kmgs955.part2.txt"
delete file G1/M00/00/00/rBABKVe8AKKAJpMZAAAAD61kmgs955.part2.txt return: 1
delete file G1/M00/00/00/rBABKVe8AKKAJpMZAAAAD61kmgs955.bin return: 1
bool(true)
tracker_close_all_connections result: 1

 4.php客户端测试

[root@img01 web_test]# echo 'php_upload_test'  >/tmp/upload.txt
[root@img01 web_test]# vim test.php
<?php
        var_dump(function_exists('fastdfs_storage_upload_by_filename')); 
        $ret = fastdfs_storage_upload_by_filename('/tmp/upload.txt'); 
        var_dump($ret); 
?>

 5.上传效果

[root@img01 web_test]# /usr/local/php/bin/php test.php
bool(true)
array(2) {
  ["group_name"]=>
  string(2) "G1"
  ["filename"]=>
  string(44) "M00/00/00/rBABKVe4oo6AZT5NAAAAEIxdRHw352.txt"
}

 

5.fastdfs 本地配置文件上传

[root@tracker02 ~]# fdfs_upload_file /etc/fdfs/client.conf /etc/passwd
group1/M00/00/01/CgEIN1lxYSiAaD0bAAAElZaUMW08428299

 

 

 

 

http://192.168.1.29/G1/M00/00/00/rBABKVe4oo6AZT5NAAAAEIxdRHw352.txt

posted @ 2016-08-23 16:02  sunmmi  阅读(503)  评论(0)    收藏  举报