Ubuntu上 安装 FastDFS
2020-06-01 本文已影响0人
月夜一千
我是按照 XUDC写的文章 在我虚拟机上装的。我认为fastdfs和nginx版本相差不要太大应该是可以安装的,这篇文章流程都是按原文来的,我简略记录下熟悉下毕竟还挺麻烦。可以看原文
1.用到的压缩包
安装包名称 | 下载地址 |
---|---|
libfastcommon | https://github.com/happyfish100/libfastcommon |
fastdfs-6.06.zip | https://github.com/happyfish100/fastdfs/releases |
fastdfs-nginx-module | https://github.com/happyfish100/fastdfs-nginx-module |
nginx (我安装的时1.7.10) | http://nginx.org/download |
2.先安装依赖
# 更新源
sudo apt-get update
# 安装c++ 依赖库
sudo apt-get install build-essential
sudo apt-get install libtool
# 安装openssl 依赖 用于nginx
sudo apt-get install openssl
# 安装pcre 依赖
sudo apt-get install libpcre3 libpcre3-dev
# 安装zlib 依赖 当时把1看成L nginx时会报错
sudo apt-get install zlib1g-dev
3.安装FastDFS
3.1 安装 libfastcommon
libfastcommon是一款从FastDFS项目中剥离出来的C基础库
# 解压 libfastcommon-master.zip
unzip libfastcommon-master.zip
# 进入 libfastcommon-master/
cd libfastcommon-master
# 执行命令 如果报错的话可能是依赖没装好
./make.sh
./make.sh install
3.2 安装 fastdfs
# 回到用户主目录,解压fastdfs-xx.zip
cd ..
unzip fastdfs-xx.zip
# 进入解压后的fastdfs-xx,执行命令
cd fastdfs-xx
./make.sh install
3.3 配置tracker
# 复制tracker.conf.sample
sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
# 在 /home/username/ 目录中创建目录 fastdfs/tracker
mkdir -p /home/username/fastdfs/tracker
# 编辑/etc/fdfs/tracker.con配置文件
# 修改内容
base_path = /home/xxx/fastdfs/tracker
3.4 配置存储storage
# 复制storage.conf.sample
sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
# 在/home/xxx/fastdfs/ 目录中创建storage目录
mkdir -p /home/xxx/fastdfs/storage
# 编辑/etc/fdfs/storage.conf配置文件
base_path = /home/xxx/fastdfs/storage
tracker_server = 服务器ip:22122
3.5 启动tracker 和 storage
sudo /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
sudo /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
# 启动 成功 的话会有
# fdfs_trackerd already running, pid: 11111
3.6 测试安装状态
sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
# 编辑/etc/fdfs/client.conf配置文件 修改内容
base_path = /home/xxx/fastdfs/tracker
tracker_server = ip:22122
# 上传文件测试 /xx/xx.png为上传的图片
fdfs_upload_file /etc/fdfs/client.conf /xx/xx.png
# 返回字符串路径表示成功
/group1/M00/00/00/wKgDb17S6NWAMK-UAACdyH9JNRs343.PNG
4.安装Nginx并添加fastdfs模块
# 回到用户目录,解压nginx-1.7.10.tar.gz
tar -zxvf nginx-1.7.10.tar.gz
# 解压 fastdfs-nginx-module-master.zip
unzip fastdfs-nginx-module-master.zip
# 进入nginx-1.7.10目录
cd nginx-1.xx
# 执行命令
./configure --prefix=/usr/local/nginx/ --add-module=/home/xx/fastdfs-nginx-module-master/src/
–add-module= 后边是fastdfs-nginx-module-master解压后的绝对路径下的/src目录
# 在nginx-1.xx目录下执行
make
make install
我这里是make命令报错,最后查了下报错信息,然后修改了一个配置文件的代码,注释掉报错的代码 又运行了下
# 复制/mod_fastdfs.conf
sudo cp fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
# 修改 /etc/fdfs/mod_fastdfs.conf
connect_timeout = 10
tracker_server = 服务器ip:22122
url_have_group_name = true
store_path0 = /home/xx/fastdfs/storage
# 复制http.conf
sudo cp fastdfs-6.xx/conf/http.conf /etc/fdfs/http.conf
# 复制mime.types
sudo cp fastdfs-6.xx/conf/mine.types /etc/fdfs/mime.types
# 修改Nginx配置
/usr/local/nginx/conf/nginx.conf
http server修改为以下
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
# 启动nginx
sudo /usr/loacl/nginx/sbin/nginx
访问下刚才的图片:
屏幕截图(6).png