A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

1.安装gcc等编译环境
[AppleScript] 纯文本查看 复制代码
yum install -y gcc gcc-c++

2. 安装libevent
[AppleScript] 纯文本查看 复制代码
yum -y install libevent

3. 下载需要安装的文件
[AppleScript] 纯文本查看 复制代码
libfastcommon wget [url=https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz]https://github.com/happyfish100/ ... chive/V1.0.7.tar.gz[/url]
FastDFS wget [url=https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz]https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz[/url]
fastdfs-nginx-module_v1.16 wget [url=http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz]http://jaist.dl.sourceforge.net/ ... module_v1.16.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] 纯文本查看 复制代码
tar -zxvf libfastcommonV1.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] 纯文本查看 复制代码
tar -zxvf V5.05.tar.gz -C /usr/local
cd /usr/local/V5.05/
./make.sh && ./make.sh install  #编译之后接着进行安装
cp /usr/local/V5.05/conf/* /etc/fdfs/

6. 配置Tracker服务器
[AppleScript] 纯文本查看 复制代码
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] 纯文本查看 复制代码
cd /etc/fdfs
vim storage.conf
    group_name=group1 #配置组名
    base_path=/home/yuqing/fastdfs    改为:  base_path=/home/fastdfs
    store_path0=/home/yuqing/fastdfs  改为: store_path0=/home/fdfs_storage 
    tracker_server=192.168.172.20: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] 纯文本查看 复制代码
cd /etc/fdfs/
vim client.conf
   base_path=/home/fastdfs
   tracker_server= 118.25.222.158:22122
   /usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr1/aaa.jpg
得到图片地址:[img]http://192.168.172.20/group1/M00/00/00/wKisFFpBG9eAHaQvAAAWKd1hQR4158_big.jpg[/img] 

9. fastdfs-nginx-module的安装配置
[AppleScript] 纯文本查看 复制代码
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.25.222.158:22122 
    #tracker_server=118.25.222.158:22122 #(多个tracker配置多行)
    url_have_group_name=true        #url中包含group名称
    store_path0=/home/fdfs_storage  #指定文件存储路径(上面配置的store路径)
cp /usr/lib64/libfdfsclient.so /usr/lib/
mkdir -p /var/temp/nginx/client    

10. 安装nginx
[AppleScript] 纯文本查看 复制代码
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/V5.05/conf
cp http.conf mime.types /etc/fdfs/
mkdir /usr/local/nginx/logs # 创建logs目录
cd /usr/local/nginx/conf/
vim nginx.conf
    修改pid 为/usr/local/nginx/logs
    server_name指定118.25.222.158
    location /group1/M00/ {
            root   /home/fastdfs_storage/data;
            ngx_fastdfs_module;
        }
cd /usr/local/nginx/sbin/
./nginx  启动
systemctl stop firewalld 关闭防火墙
测试        











0 个回复

您需要登录后才可以回帖 登录 | 加入黑马