FastDFS安装的过程

1、安装libevent

 

yum install libevent

 

 

2、下载FastDFS程序包

https://code.google.com/p/fastdfs/downloads/list?q=label:Featured

wget http://fastdfs.googlecode.com/files/FastDFS_v3.05.tar.gz

 

3、解压安装

 

tar zxvf FastDFS_v3.05.tar.gz2
cd FastDFS/
./make.sh
./make.sh install

 

 

 

4、安装完成后,fastdfs默认的配置文件被放置在/etc/fdfs 目录下面,包含了client.conf  http.conf  mime.types  storage.conf  tracker.conf五个文件,fastdfs进程的启动是以加载的配置文件区分的。源码包中都包含了这三个配置文件。

 

5、修改tracker.conf 配置文件

base_path=/opt/fdfs

http.server_port=80

 

    启动tracker进程

 

fdfs_trackerd /etc/fdfs/tracker.conf

 

 

    检测状态

 

netstat -tupln|grep tracker

    如果22122被监听说明启动成功

 

 

6、修改storage.conf配置文件

base_path=/opt/fdfs

store_path0=/opt/fdfs

tracker_server=192.168.1.103:22122 (IP改为你指定的IP)

http.server_port=80

 

启动storage进程

 

fdfs_storaged /etc/fdfs/storage.conf

 

 

    检测监听

 

netstat -tupln | grep storage

    如果23000被监听说明启动成功

 

 

7、修改client.conf配置文件

tracker_server=192.168.1.103:22122

http.tracker_server_port=80

 

8、测试上传文件

 

fdfs_upload_file /etc/fdfs/client.conf 123.jpg

   返回如下字符串

 

   group1/M00/00/00/CgEGflAqaFW4hENaAAACo8wrbSE16.jpg

 

9、在storage server上安装nginx

安装nginx关于fastdfs集合的扩展模块,注意这个模块nginx默认的编译模块中没有,需手动下载安装,可以到https://code.google.com/p/fastdfs/downloads/list?q=label:Featured下载

 

tar xf fastdfs-nginx-module_v1.15.tar.gz
cd fastdfs-nginx-module

 

 

10、下载nginx安装

tar xf nginx-1.4.1.tar.gz
cd nginx-1.4.1
./configure \
   --prefix=/usr 
....(限于篇幅省略)
   --add-module=/root/soft/fastdfs-nginx-module/src  (fastdfs的nginx模块)
make
make install

 

cp /root/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ 
vim /etc/fdfs/mod_fastdfs.conf 
base_path=/tmp 改为 base_path=/opt/fdfs 
tracker_server=tracker:22122 改为 tracker_server=192.168.1.103:22122 
store_path0=/home/yuqing/fastdfs 改为 store_path0=/data/fastdfs

 

 

11、配置nginx

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

 

 

location /group1/M00{

  alias   /data/fastdfs/data;

  ngx_fastdfs_module;

}

/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx

 

 

http://192.168.1.103/group1/M00/00/00/CgEGflAqaFW4hENaAAACo8wrbSE16.jpg

出现400错误,需要修改

vi /etc/fdfs/mod_fastdfs.conf

    url_have_group_name = false 改为 true      #关于啥意思,配置文件中有解释

    重启nginx 即可访问

 

12、FastDFS客户端PHP扩展库的安装与配置

目前FastDFS的PHP扩展不支持Windows平台,在安装PHP扩展前,应先安装FastDFS客户端(客户端安装过程同上)和PHP,扩展库安装如下所示:

cd php_client (进入FastDFS安装包/FastDFS/php_client)
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cp ../conf/client.conf /etc/fdfs/ 
(修改client.conf, eg:tracker_server=192.168.1.103:22122和http.tracker_server_port=80)
cat fastdfs_client.ini >> /usr/local/php/etc/php.ini

   修改php.ini的配置项目,如:

   fastdfs_client.tracker_group_count = 1

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

   注:检查看extension = "fastdfs_client.so"是否在extension_dir后,或者直接具体路径如:extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/fastdfs_client.so"

 

  重启web服务器即可。在php_client已经有扩展函数说明和程序示例。

 

FastDFS常用操作命令

tracker server
启动
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

重启
/usr/local/bin/restart.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

停止
/usr/local/bin/stop.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

storaged server
启动
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf 

重启
/usr/local/bin/restart.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

停止
/usr/local/bin/stop.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf

 

 

安装环境:

CentOS 6.3

 

参考:

http://my.oschina.net/guol/blog/72845

http://www.it165.net/admin/html/201308/1628.html

http://blog.csdn.net/caleng/article/details/5652693

http://www.zrwm.com/?p=4567

 

你可能感兴趣的:(nginx,fastDFS)