yum install gcc-c++ -y
yum -y install libevent
yum install perl*
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
tar -zxvf libfastcommonV1.0.7.tar.gz
./make.sh
./make.sh install
cp /usr/lib64/libfastcommon.so /usr/lib/
tar -zxvf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh
/make.sh install
cd conf
cp * /etc/fdfs/
vim /etc/fdfs/tracker.conf
mkdir /opt/fastdfs
启动服务
mkdir /usr/local/fdfs
拷贝安装目录下stop.sh 和restart.sh 到/usr/local/fdfs/
cp restart.sh /usr/local/fdfs/
cp stop.sh /usr/local/fdfs/
vim /etc/init.d/fdfs_trackerd
chkconfig --add fdfs_trackerd
然后可以用service fdfs_trackerd start
启动测试 如下图
修改配置文件
vim /etc/fdfs/storage.conf
保存退出
创建fdfs_storage文件夹
mkdir /opt/fastdfs/fdfs_storage
设置服务
vim /etc/init.d/fdfs_storaged
chkconfig - -add fdfs_storaged
启动服务
service fdfs_storaged start
FastDFS安装成功可通过/usr/bin/fdfs_test测试上传、下载等操作。
修改/etc/fdfs/client.conf
vim /etc/fdfs/client.conf
base_path=/opt/fastdfs
tracker_server=你自己的ip(内网):22122
比如将/root下的日志上传到FastDFS中:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/winteriscoming.jpg
对应的上传路径:
/opt/fastdfs/fdfs_storage/data /00/00/wKhDo1qipbiAJC6iAAB1tayPlqs094_big.jpg
但是此时是无法通过浏览器访问的,因为FastDFS缺少web服务器,我们需要一个nginx来代理
上传fastdfs-nginx-module_v1.16.tar.gz上传到 /usr/local,并解压
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
编辑配置文件:修改config文件将/usr/local/路径改为/usr/(这里要修改三个路径)
vim fastdfs-nginx-module/src/config
将FastDFS-nginx-module/src下的mod_fastdfs.conf拷贝至/etc/fdfs/下
cp mod_fastdfs.conf /etc/fdfs/
并修改mod_fastdfs.conf的内容:
vim /etc/fdfs/mod_fastdfs.conf
继续修改 url中包含group名称
继续修改 #指定文件存储路径
将libfdfsclient.so拷贝至/usr/lib下
cp /usr/lib64/libfdfsclient.so /usr/lib/
创建nginx/client目录
mkdir -p /var/temp/nginx/client
安装环境(前面都正常的话这一步可以不做):
安装pcre库
yum -y install pcre-devel
安装zlib库
yum install -y zlib-devel
上传nginx压缩包到/usr/local目录下,解压
tar -zxvf nginx-1.12.2.tar.gz
添加fastdfs-nginx-module模块
cd nginx-1.12.2
命令行输入
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--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
编辑nginx.conf
vim /usr/local/nginx/conf/nginx.conf
建立脚本把nginx交给service管理
cd /etc/init.d
vim nginx
#!/bin/bash
#Startup script for the nginx Web Server
#chkconfig: 2345 85 15
nginx=/usr/local/nginx/sbin/nginx
conf=/usr/local/nginx/conf/nginx.conf
case $1 in
start)
echo -n "Starting Nginx"
$nginx -c $conf
echo " done."
;;
stop)
echo -n "Stopping Nginx"
killall -9 nginx
echo " done."
;;
test)
$nginx -t -c $conf
echo "Success."
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
echo " done."
;;
restart)
$nginx -s reload
echo "reload done."
;;
*)
echo "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac
启动,停止,重启nginx命令
service nginx start
service nginx stop
service nginx restart
vim /etc/rc.d/rc.local
service iptables stop
永久关闭
chkconfig iptables off
测试
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/ty.jpg