1.先安装libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/master.zip unzip master.zip cd libfastcommon-master/ ./make.sh ./make.sh install2.安装fastdfs
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.05/FastDFS_v5.05.tar.gz ./make.sh ./make.sh install
2.1 创建fastdfs 账号,用于管理FastDFS
useradd fastdfs -M -s /sbin/nologin3.安装Nginx
3.1先安装依赖
yum -y install gcc gcc+ gcc-c++ openssl openssl-devel pcre pcre-devel3.2添加运行Nginx 的用户(www)及用户组(www)
useradd www -M -s /sbin/nologin
3.3安装fastdfs-nginx-module
wget http://downloads.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz tar xf fastdfs-nginx-module_v1.16.tar.gz3.4安装nginx
wget http://nginx.org/download/nginx-1.6.3.tar.gz tar zxvf nginx-1.6.3.tar.gz cd nginx-1.6.3 yum install gd-devel ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_image_filter_module --add-module=../fastdfs-nginx-module/src make make install4.配置tracker
4.1创建tracker 数据及日志存放目录
mkdir -p /data/fastdfs/tracker4.2修改FastDFS 配置文件tracker.conf
vim /etc/fdfs/tracker.conf 修改basepath为 /data/fastdfs/tracker4.3把tracker 交给service 管理,并设置开机自启动
cp /usr/local/src/FastDFS/init.d/fdfs_trackerd /etc/init.d/ chkconfig --add fdfs_trackerd chkconfig fdfs_trackerd on5.配置storage group1
5.1创建数据存放目录
mkdir -p /data/fastdfs/storage5.2修改FastDFS 配置文件storage.conf
vim /etc/fdfs/storage.conf ##运行FastDFS 的用户组 run_by_group=fastdfs ##运行FastDFS 的用户 run_by_user=fastdfs file_distribute_path_mode=1 rotate_error_log=true 修改base_path为/data/fastdfs/ store_path0=为/data/fastdfs/storage 和tracker_server地址等5.3把nginx 模块配置文件拷贝到“/etc/fdfs”里,并修改
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/ vim /etc/fdfs/mod_fastdfs.conf connect_timeout=30 tracker_server=192.168.10.11:22122 group_name=g1 url_have_group_name = true store_path_count=1 store_path0=/data/fastdfs/storage5.4修改Nginx 配置文件
5.5 把storage 交给service 管理,并设置开机自启动
cp /usr/local/src/FastDFS/init.d/fdfs_storaged /etc/init.d/ chkconfig --add fdfs_storaged chkconfig fdfs_storaged on service fdfs_storaged start6.复制fastdfs配置到et/fdfs
cd FastDFS/conf cp http.conf mime.types /etc/fdfs
需要注意的问题
1.需要修改/fastdfs-nginx-module/src/config里的相关路径
修改fastdfs-nginx-module的config文件 原来的内容是 CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/" vim /home/nginx/fastdfs-nginx-module/src/config,修改为 CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon"