1.安装gcc等编译环境
[AppleScript] 纯文本查看 复制代码
1
|
yum install - y gcc gcc - c + +
|
2. 安装libevent
[AppleScript] 纯文本查看 复制代码
1
|
yum - y install libevent
|
3. 下载需要安装的文件
[AppleScript] 纯文本查看 复制代码
1
2
3
4
|
libfastcommon wget [ url = https : / / github.com / happyfish 100 / libfastcommon / archive / V 1.0 . 7. tar.gz]https : / / github.com / happyfish 100 / ... chive / V 1.0 . 7. tar.gz[ / url ]
FastDFS wget [ url = https : / / github.com / happyfish 100 / fastdfs / archive / V 5.0 5. tar.gz]https : / / github.com / happyfish 100 / fastdfs / archive / V 5.0 5. tar.gz[ / url ]
fastdfs - nginx - module_v 1.1 6 wget [ url = http : / / jaist.dl.sourceforge.net / project / fastdfs / FastDFS% 20 Nginx% 20 Module% 20 Source% 20 Code / fastdfs - nginx - module_v 1.1 6. tar.gz]http : / / jaist.dl.sourceforge.net / ... module_v 1.1 6. tar.gz[ / url ]
nginx wget [ url = http : / / nginx.org / download / nginx -1.7 . 0. tar.gz]http : / / nginx.org / download / nginx -1.7 . 0. tar.gz[ / url ]
|
4. 编译和安装libfastcommon
[AppleScript] 纯文本查看 复制代码
1
2
3
4
5
6
|
tar - zxvf libfastcommonV 1.0 . 7. tar.gz - C / usr / local /
cd / usr / local / libfastcommon -1.0 . 7 /
. / make .sh #编译
. / make .sh install #安装
#libfastcommon安装好后会在/usr/lib64 目录下生成,同时需要将其拷贝到usr/lib目录
cp libfastcommon.so / usr / lib
|
5. 安装Tracker
[AppleScript] 纯文本查看 复制代码
1
2
3
4
|
tar - zxvf V 5.0 5. tar.gz - C / usr / local
cd / usr / local / V 5.0 5 /
. / make .sh & & . / make .sh install #编译之后接着进行安装
cp / usr / local / V 5.0 5 / conf / * / etc / fdfs /
|
6. 配置Tracker服务器
[AppleScript] 纯文本查看 复制代码
1
2
3
4
5
6
7
|
cd / etc / fdfs
vim tracker.conf
base_path = / home / fastdfs
http.server_port = 80 #配置http端口
mkdir / home / fastdfs
/ usr / bin / fdfs_trackerd / etc / fdfs / tracker.conf restart 启动
注意:在 / home / fastdfs / 目录下生成两个目录, 一个是数据,一个是日志;
|
7. 配置和启动Storage
[AppleScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
|
cd / etc / fdfs
vim storage.conf
group_name = group 1 #配置组名
base_path = / home / yuqing / fastdfs 改为 : base_path = / home / fastdfs
store_path 0 = / home / yuqing / fastdfs 改为: store_path 0 = / home / fdfs_storage
tracker_server = 192.1 68.1 72.2 0 : 22122
http.server_port = 88
mkdir / home / fdfs_storage
/ usr / bin / fdfs_storaged / etc / fdfs / storage.conf restart 启动
ls / home / fdfs_storage / data
|
8. 使用fastdfs自带的工具测试
[AppleScript] 纯文本查看 复制代码
1
2
3
4
5
6
|
cd / etc / fdfs /
vim client.conf
base_path = / home / fastdfs
tracker_server = 118.2 5.2 22.1 58 : 22122
/ usr / bin / fdfs_test / etc / fdfs / client.conf upload / usr 1 / aaa.jpg
得到图片地址 : [img]http : / / 192.1 68.1 72.2 0 / group 1 / M 00 / 00 / 00 / wKisFFpBG 9 eAHaQvAAAWKd 1 hQR 4158 _big.jpg[ / img]
|
9. fastdfs-nginx-module的安装配置
[AppleScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
|
cd / usr / local / fastdfs - nginx - module / src /
修改config文件,将文件中的所有 / usr / local / 路径改为 / usr /
cp mod_fastdfs.conf / etc / fdfs /
vi / etc / fdfs / mod_fastdfs.conf
base_path = / home / fastdfs
tracker_server = 118.2 5.2 22.1 58 : 22122
#tracker_server=118.25.222.158:22122 #(多个tracker配置多行)
url_have_group_name = true #url中包含group名称
store_path 0 = / home / fdfs_storage #指定文件存储路径(上面配置的store路径)
cp / usr / lib 64 / libfdfsclient.so / usr / lib /
mkdir - p / var / temp / nginx / client
|
10. 安装nginx
[AppleScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
tar - zxvf nginx -1.8 . 0. tar.gz - C / usr / local /
yum install pcre
yum install pcre - devel
yum install zlib
yum install zlib - devel
yum install openssl
yum install openssl - devel
cd / usr / local / nginx -1.7 . 0 /
. / 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
cd / usr / local / V 5.0 5 / conf
cp http.conf mime. types / etc / fdfs /
mkdir / usr / local / nginx / logs # 创建logs目录
cd / usr / local / nginx / conf /
|