安装FastDFS
一:安装tracker
1:安装 gcc:yum install gcc-c++
2:FastDFS 依赖 libevent 库,需要安装:yum -y install libevent
3:libfastcommon 是 FastDFS 官方提供的,libfastcommon 包含了 FastDFS 运行所需要的一些基础库
将 libfastcommonV1.0.7.tar.gz 拷贝至/usr/local/下
cd /usr/local
tar -zxvf libfastcommonV1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
注意:libfastcommon 安装好后会自动将库文件拷贝至/usr/lib64 下,由于 FastDFS 程
序引用 usr/lib 目录所以需要将/usr/lib64 下的库文件拷贝至/usr/lib 下。
4: 在home文件夹中创建一个FastDFS文件夹用于存储 tracker和storage的数据和日志(这里用一台虚拟机将tracker和storage放 在一起了),并创建tracker和storage文件夹用于区分
5:tracker编译安装
将 FastDFS_v5.05.tar.gz 拷贝至/usr/local/下
tar -zxvf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh 编译
./make.sh install 安装
安装成功后,将这个安装目录中的conf文件夹中的配置文件复制到 /etc/fdfs中,进入/etc/fdfs中
拷贝一份新的tracker.conf.sample 并修改 tracker.conf
cp tracker.conf.sample tracker.conf
vi tracker.conf
将下面配置改为如下
base_path=/home/FastDFS/tracker http.server_port=80 |
6:启动
执行命令 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
二:安装storage
1: libevent 库 libfastcommon同tracker一样,因为在同一台虚拟机,这里就不安装了
2:storage安装编译:
因为上面已经将FastDFS解压安装过了,那么在 /etc/fdfs中已经有storage.conf配置文件了,这里只需要修改配置文件就成
拷贝一份新的tracker.conf.sample 并修改 tracker.conf
cp storage.conf.sample storage.conf
vi storage.conf
将配置改为如下: 其中的tracker_server 改为本虚拟机IP地址,端口号默认为22122,
group_name=group1 http.server_port=80 |
3:启动:
执行命令: /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
三:安装fastdfs-nginx-module:
安装该module的原因是:只是安装了tracker和storage,只能进行上传和下载。不能在浏览器访问,不能进行http下载
这个模块是安装在storage服务器上的,因为本机tracker和storage是在一起的,那就在这个服务器上安装
1:上传fastdfs-nginx-module到服务器
将FastDFS-nginx-module_v1.16.tar.gz上传至服务器,并解压到/usr/local/ 下 , 解压完成进入src目录
2:修改相关配置
将mod_fastdfs.conf配置文件复制到 /etc/fdfs中,并修改相关配置
base_path=/home/FastDFS/tracker tracker_server=192.168.101.131:22122 |
3:复制文件
将 libfdfsclient.so 拷贝至/usr/lib 下
cp /usr/lib64/libfdfsclient.so /usr/lib/
4:创建nginx/client目录
mkdir -p /var/temp/nginx/client
5:安装nginx
将 nginx-1.8.0.tar.gz 拷贝到/usr/local 下
解压 nginx-1.8.0.tar.gz
进入 nginx-1.8.0 目录,执行如下配置命令
./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi \ --add-module=/usr/local/fastdfs-nginx-module/src |
然后执行命令编译安装 make && make install
完成后会在/usr/local下出现nginx文件夹
6:修改配置文件
进入/usr/local/FastDFS/conf 中,将两个文件复制出来
cd /usr/local/FastDFS/conf
cp http.conf mime.types /etc/fdfs/
创建nginx日志目录
mkdir /usr/local/nginx/logs
进入/usr/local/nginx/conf 中,修改配置文件
cd /usr/local/nginx/conf
vi nginx.conf
做如下修改
7:启动
执行命令: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
表示以nginx.conf的配置来启动nginx
四:总结
查看tracker、storage、nginx的进程
将测试的文件在浏览器访问