首页 » SEO优化 » phpfastdfs扩大安装技巧_轻量级分布式文件系统FastDFS安装和调试

phpfastdfs扩大安装技巧_轻量级分布式文件系统FastDFS安装和调试

duote123 2024-11-15 0

扫一扫用手机浏览

文章目录 [+]

wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz

phpfastdfs扩大安装技巧_轻量级分布式文件系统FastDFS安装和调试

wget http://nginx.org/download/nginx-1.4.5.tar.gz

phpfastdfs扩大安装技巧_轻量级分布式文件系统FastDFS安装和调试
(图片来自网络侵删)

wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz

1. 安装libevent(5.X非必须步骤)

wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

tar -zvxf libevent-2.0.21-stable.tar.gz

cd libevent-2.0.21-stable

./configure --prefix=/usr (必须安装到这里)

make && make install

ln -s /usr/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

ps : 我没有安装在那里貌似也可以

./configure --prefix=/usr/local/libevent-2.0.21-stable

make && make install

ln -s /usr/local/libevent-2.0.21-stable/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

2. 安装FastDFS

tar zxvf FastDFS_v5.01.tar.gz

cd FastDFS

vi make.sh (修正\公众#WITH_LINUX_SERVICE=1\"大众为WITH_LINUX_SERVICE=1)

./make.sh

./make.sh install

3. Storage上安装nginx的附加模块

wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz

tar -zxvf fastdfs-nginx-module_v1.15.tar.gz

安装 ngx_cache_purge-2.1 和 ngx_slowfs_cache-1.9 模块

unzip ngx_slowfs_cache-master.zip

unzip ngx_cache_purge-master.zip

编译nginx

./configure --prefix=/usr/local/nginx-1.4.2 --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_mp4_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_stub_status_module --with-http_ssl_module --with-http_spdy_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_dav_module --with-http_flv_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --add-module=../ngx_cache_purge-master --add-module=../ngx_slowfs_cache-master --add-module=/root/soft/fastdfs-nginx-module/src

make && make install

问题 : service nginx restart 成功 但项目失落败 完成下方配置 就可以了

下方的一些参数配置须要编辑/etc/fdfs 一些配置文件

mkdir -p /data/fastdfs/tracker

mkdir -p /data/fastdfs/storage

/

cp /root/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

vi /etc/fdfs/mod_fastdfs.conf

修正内容为下方信息

base_path=/data/fastdfs

tracker_server=192.168.1.168:22122

store_path0=/data/images

/

4. 配置tracker

vi /etc/fdfs/tracker.conf

base_path=/data/fastdfs/tracker

启动:service fdfs_trackerd restart

这里 tracker.conf 配置结束了

5. 配置storage

vi /etc/fdfs/storage.conf

group_name=group1 ==> 此台storage server所属的做事器组名。

base_path=/data/fastdfs/storage ==> 放置data和log的目录。
此路径必须担保存在。

store_path0=/data/fastdfs/storage ==> 放置文件的目录,此路径必须担保存在.

tracker_server=192.168.112.131:22122 ==> 可以添加多个tracker_server,如下行

tracker_server=192.168.112.131:22122

http.disabled=true ==> 关闭内置的web server,如果有就设置,否则就不用设置。

http.server_port=80 ==> web server的端口改成8080(与nginx 端口同等)

这里 storage.conf 配置结束了

cp /root/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

vi /etc/fdfs/mod_fastdfs.conf

base_path=/data/fastdfs/storage ==>放置log的目录,与storage中的配置保持同等。

tracker_server=192.168.112.131:22122

#tracker_server=192.168.112.131:22122

group_name=group1 ==> 此台storage server所属的做事器组名。

url_have_group_name = false ==> 在URL中包含group名称。
一定要设置true 如果设置成true 可以在nginx 中 location 中设置

store_path0=/data/fastdfs/storage ==> 放置文件的目录,与storage中保持同等

response_mode=proxy ==> 对文件同步延迟的处理办法,通过redirect跳转和proxy代理两种办法办理

group_count=0 ==> group的个数,在本示例中有两个group,以是设为2,如果只有一个group则设置为0,而不是为1

启动:service fdfs_storaged restart

开放端口

# fdfs

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT

这里fastdfs 配置结束了

接下来配置nginx php关联 fastdfs

6. nginx配置

server节点添加:

vi /usr/local/nginx/conf/nginx.conf

location ~ /M00

{

# slowfs_cache fastcache;

# slowfs_cache_key $uri;

# slowfs_cache_valid 1d;

# add_header X-Cache '$slowfs_cache_status from $host';

# expires max;

if ($request_filename ~ [a-zA-Z0-9]+-([0-9]+)-([0-9]+).(gif|GIF|jpg|JPG|jpeg|JPEG|bmp|BMP|png|PNG)) {

rewrite ^(.)-[0-9]+-[0-9]+.(gif|GIF|jpg|JPG|jpeg|JPEG|bmp|BMP|png|PNG)$ $1.$2 break;

}

ngx_fastdfs_module;

}

7. php配置

cd /root/soft/FastDFS/php_client

/usr/local/php/bin/phpize

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

make && make install

ls /usr/local/php-5.4.17/lib/php/extensions/no-debug-non-zts-20100525/

添加fastdfs 扩展 或者直接实行 cat fastdfs_client.ini >> /usr/local/php/etc/php.ini 这个会自定将扩展模块加入到php.ini

[fastdfs]

extension=fastdfs_client.so

fastdfs_client.base_path = /data/fastdfs/tracker

fastdfs_client.connect_timeout = 2

fastdfs_client.network_timeout = 60

fastdfs_client.log_level = info

fastdfs_client.log_filename =

fastdfs_client.http.anti_steal_secret_key =

fastdfs_client.tracker_group_count = 1

fastdfs_client.tracker_group0 = /etc/fdfs/client.conf

fastdfs_client.use_connection_pool = false

fastdfs_client.connection_pool_max_idle_time = 3600

vi /etc/fdfs/client.conf

base_path=/data/fastdfs/tracker

tracker_server=192.168.112.131:22122

service php-fpm restart

重启php进程

运行测试吧:php fastdfs_test.php

8. 测试方法

1) 查看集议论形

/usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf

2)/usr/local/bin/fdfs_test conf/client.conf upload ~/11.png

1) 上传一个文件:

<pre>$tracker = fastdfs_tracker_get_connection();

var_dump($tracker);

if (!fastdfs_active_test($tracker))

{

error_log(\"大众errno: \"大众 . fastdfs_get_last_error_no() . \"大众, error info: \"大众 . fastdfs_get_last_error_info());

exit(1);

}

$storage = fastdfs_tracker_query_storage_store();

if (!$storage)

{

error_log(\公众errno: \"大众 . fastdfs_get_last_error_no() . \"大众, error info: \公众 . fastdfs_get_last_error_info());

exit(1);

}

$file_info = fastdfs_storage_upload_by_filename(\"大众/zxy.jpg\公众, null, array(), null, $tracker, $storage);

</pre>

2) 下载一个文件

<pre>$group_name=\"大众group0\"大众;

$filename=\"大众M00/00/00/wKgBpFNN-T6AQZKtAAH4P9ysWgA950.jpg\"大众;

fastdfs_storage_download_file_to_file($group_name,$filename, \公众test.jpg\公众);

</pre>

3) 删除一个文件

<pre>$group_name=\"大众group0\"大众;

$filename=\"大众M00/00/00/wKgAUE5zkhH8yBZwAAGH3hvfjJA398.jpg\"大众;

echo fastdfs_storage_delete_file($group_name, $filename);&gt;

</pre>

标签:

相关文章

语言枚举类型,探索人类语言多样性的奥秘

语言是人类交流的重要工具,也是人类文明发展的重要标志。随着全球化进程的不断推进,各种语言枚举类型应运而生。本文将从语言枚举类型的定...

SEO优化 2024-12-29 阅读0 评论0

语言栏消失,科技变革下的挑战与机遇

近年来,随着科技的飞速发展,智能手机、平板电脑等移动设备的普及,语言栏这一功能已经成为了我们日常生活中不可或缺的一部分。近期有消息...

SEO优化 2024-12-29 阅读0 评论0

语言混合现象的多元魅力与挑战

语言混合作为一种跨文化交流的现象,逐渐成为世界范围内语言学研究的热点。它不仅丰富了语言的多样性,也反映了全球化背景下人类社会的交流...

SEO优化 2024-12-29 阅读0 评论0

语言是思想的载体,介绍语言与思想的关系

在人类文明的进程中,语言一直扮演着至关重要的角色。它不仅是人们沟通交流的工具,更是承载着人类思想的载体。自古以来,人们就深知语言与...

SEO优化 2024-12-29 阅读0 评论0