1.安装依赖
# yum install unzip zip gcc-c++
nginx模块依赖
# yum -y install pcre pcre-devel
# yum -y install zlib zlib-devel
# yum -y install openssl openssl-devel
$ sudo apt-get install unzip
$ sudo apt-get install libpcre3 libpcre3-dev
$ sudo apt-get install zlib1g zlib1g-dev
$ sudo apt-get install openssl libssl-dev
2.下载必要的包
$ mkdir sofware
$ cd software
# FastDFSV5.11源码包
$ wget https://codeload.github.com/happyfish100/fastdfs/tar.gz/V5.11
$ tar -zxvf V5.11
# libfastcommon依赖库源码包
$ wget https://codeload.github.com/happyfish100/libfastcommon/tar.gz/V1.0.36
$ tar -zxvf V1.0.36
# fastdfs-nginx-module模块源码包
$ wget https://codeload.github.com/happyfish100/fastdfs-nginx-module/zip/master
$ unzip master
$ wget http://nginx.org/download/nginx-1.12.2.tar.gz
$ tar -zxvf nginx-1.12.2.tar.gz
3.安装包
$ cd libfastcommon-1.0.36/
$ ./make.sh
$ sudo ./make.sh install
$ sudo ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
$ sudo ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
$ sudo ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
$ cd ..
$ cd fastdfs-5.11/
$ ./make.sh
$ sudo ./make.sh install
$ cd ..
$ sudo mkdir -p /var/tmp/nginx/proxy
$ cd nginx-1.12.2/
$ ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/root/sofware/fastdfs-nginx-module-master/src --http-client-body-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi
$ make && sudo make install
$ sudo groupadd -f nginx
$ sudo useradd -g nginx nginx
3.配置包
$ sudo mkdir -p /FastDFS/tracker
$ sudo mkdir -p /FastDFS/storage
$ cd /etc/fdfs/
$ sudo cp client.conf.sample client.conf
$ sudo cp storage.conf.sample storage.conf
$ sudo cp tracker.conf.sample tracker.conf
# 配置tracker
$ sudo vim /etc/fdfs/tracker.conf
#设置tracker的数据文件和日志目录
base_path=/FastDFS/tracker
# 启动tracker服务
$ sudo /etc/init.d/fdfs_trackerd start
# 查看服务状态
$ sudo netstat -unltp|grep fdfs
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 14628/fdfs_trackerd
服务运行的22122端口正常
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
$ sudo vim /etc/fdfs/storage.conf
base_path=/FastDFS/storage
store_path0=/FastDFS/storage
store_path_count=1
$ tracker_server=192.168.184.132:22122
$ sudo /etc/init.d/fdfs_storaged start
$ sudo netstat -unltp|grep fdfs
tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 15063/fdfs_storaged
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 14628/fdfs_trackerd
$ sudo /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
# 编辑/etc/fdfs/client.conf配置文件
$ sudo vim /etc/fdfs/client.conf
# 修改内容:
base_path=/FastDFS/tracker
tracker_server=192.168.184.132:22122
# 上传文件测试:
$ fdfs_upload_file /etc/fdfs/client.conf /home/ubuntu/1.jpg
# 如果返回类似group1/M00/00/00/rBIK6VcaP0aARXXvAAHrUgHEviQ394.jpg的文件id则说明文件上传成功
$ sudo cp/home/ubuntu/software/fastdfs-5.11/conf/http.conf /etc/fdfs/
$ sudo cp /home/ubuntu/software/fastdfs-5.11/conf/mime.types /etc/fdfs/
$ sudo cp /home/ubuntu/software/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
$ sudo vim /etc/fdfs/mod_fastdfs.conf
base_path=/FastDFS/storage
tracker_server=192.168.184.132:22122
url_have_group_name = true
store_path0=/FastDFS/storage
$ cd /usr/local/nginx/conf/
$ sudo vim nginx.conf
server{
listen 9999;
location ~/group[0-9]/ {
root /FastDFS/storage/data;
ngx_fastdfs_module;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
$ sudo /usr/local/nginx/sbin/nginx
# 上传一个图片
$ fdfs_upload_file /etc/fdfs/client.conf /home/ubuntu/1.jpg
# 返回路径
# group1/M00/00/00/rBIK6VcaP0aARXXvAAHrUgHEviQ394.jpg的文件id则说明文件上传成功
# 在浏览器访问
http:
转载出处