fastdfs文件上传 read timeout_FastDFS+Nginx+fastdfs-nginx-module安装并测试上传文件并设置开机自启...

1:安装Git

apt-get install git

1:下载安装libfastcommon 通过git

git clone happyfish100/libfastcommon

3:进入文件夹并安装libfastcommon依赖

cd libfastcommon

./make.sh ./make.sh install

4:下载安装FastDFS

wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

5:解压文件 并进入

tar -zxvf V5.11.tar.gz cd fastdfs-5.11

6:编译、安装

./make.sh

./make.sh install

7:创建软链接

ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so 根据自己文件中显示内容操作

8:// 创建libfdfsclient.so软链接

ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so 同上

9:FastDFS服务脚本设置的在bin 目录下即: /usr/local/bin,但要求在 /usr/bin/ 下,所以需要建立 /usr/bin 到 /usr/local/bin 的软链接 即fastdfs-nginx-module/src下的config 不建立需要修改 去除local。

ln -s /usr/bin/fdfs_trackerd /usr/local/bin

ln -s /usr/bin/fdfs_storaged /usr/local/bin

ln -s /usr/bin/stop.sh /usr/local/bin

ln -s /usr/bin/restart.sh /usr/local/bin

10:用于存储tracker server的数据和日志 在/home文件夹下创建所需的文件 可通过xshell 连接后自行创建 进入home 文件夹下

mkdir -p /guoguo/fastdfs/log

11:用于存储storage server的数据和日志

mkdir -p /guoguo/fastdfs/log

12:上传的资源文件

mkdir -p /guoguo/fastdfs/storage0

13:创建临时目录:

mkdir -p /guoguo/fastdfs/temp

14:切换路径, 将etc/fdfs 下的tracker.conf.sample 等三个文件复制 或不复制 并修改文件名 可通过xshell 完成

cd /etc/fdfs

cp tracker.conf.sample tracker.conf

cp storage.conf.sample storage.conf

cp client.conf.sample client.conf

15:依次修改上述文件 若没有安装vim 先安装

sudo apt-get install vim 

vim tracker.conf

修改tracker.conf

修改内容如下

启用配置

disabled=false

tracker服务器端口(默认22122)

port=22122

Tracker 存储数据和日志根目录

base_path=/home/guoguo/fastdfs/log

HTTP 服务端口

http.server_port=80 保存并退出

修改storage.conf

vim storage.conf

修改部分内容如下:

启用配置文件

disabled=false

storage服务器端口(默认23000)

port=23000

将base_path路径改为刚新建的storage目录

base_path=/home/guoguo/fastdfs/log

store_path0=/home/guoguo/fastdfs/storage0

指定tracker服务器地址,此处是上面预定好的IP 虚拟机 ifconfig

tracker_server=192.168.161.128:22122

HTTP 访问文件的端口,此处需要与后面Nginx监听的端口保持一致

http.server_port=80

修改client.conf

base_path=base_path=/home/guoguo/fastdfs/log 日志

tracker_server=192.168.161.128:22122

http.tracker_server_port=8080

16:启动tracker和storage

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

17: 若已经启动可查看端口是否监听

netstat -unltp |grep fdfs

18:测试上传图片

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf 图片路径

返回group1/M00/00/00/.....

--------------安装nginx-------已安装情况下执行下列----

安装nginx 见:人类身份验证 - SegmentFault 选择性摘录

19:进入local文件夹下 安装fastdfs-nginx-module

cd /usr/local

git clone happyfish100/fastdfs-nginx-module

配置nginx

20:若已安装直接进入文件夹编译即可 此前已安装过 不多添加

进入nginx 解压文件

cd nginx-1.13.12

配置: 其实只添加 --add-moudle=..; 即可 根据自己以前安装定

./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/root/pcre-8.40 --with-zlib=/root/zlib-1.2.11 --with-openssl=/root/openssl-1.0.2o --add-module=/usr/local/fastdfs-nginx-module/src

make

make install

查看版本模块是否添加进入了fastdfs-nginx-module/src

/usr/local/nginx/nginx -V

21: 测试安装是否成功 并关闭

/usr/local/nginx/nginx /usr/local/nginx/nginx -s stop

22:需要将fastdfs-nginx-module 源码中的配置文件到/etc/fdfs 目录, 并修改

其中src下的config 没建立软连接的情况下去除local。

cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

(可通过xshell窗口 操作也可通过命令)

vim /etc/fdfs/mod_fastdfs.conf (修改后记住保存)

connect_timeout=10 (链接时长更改到10s即可)

base_path=/home/guoguo/fastdfs/temp

tracker服务IP和端口

tracker_server=192.168.161.128:22122

group_name=group1

url_have_group_name=true (更改为true 前缀)

store_path0=/home/guoguo/fastdfs/storage0

23:复制 FastDFS 的部分配置文件到/etc/fdfs 目录下

cd /root/fastdfs-5.11/conf/

cp http.conf mime.types anti-steal.jpg /etc/fdfs/ (需要读取http.conf)

24:配置 nlocal下的nginx.conf 使其访问storage文件 添加如下:

vim /usr/local/nginx//nginx.conf (可通过命令 也可通过xshell窗口)

在80端口下添加fastdfs-nginx模块 端口保持一致:(location的配置,如果有多个group则配置

location ~/group([0-9])/M00 ):

location ~/group([0-9])/M00 {

ngx_fastdfs_module;

}

反是VIM操作记住保存:wq

25:以上都关闭防火墙 然后启动nginx

/usr/local/nginx/nginx

例如出现以下:则表示成功

ngx_http_fastdfs_set pid=129120

26:启动成功后,重新访问已上传的图片,若成功,则表示配置成功

http://192.168.161.128/group1/M00/00/00/wKihgF1D4dOAecX-

AAAtpJv7PyU792_big.png

27:创建一个开机启动的脚本:

vim /etc/init.d/nginx

28:-----粘贴进去

8b57d244f7b79fe22837f158097c9464.png

77eb3b3e0faa636fc6898d350e5f2d7d.png

87fcc93f941a754b80c7e4636e310b05.png

保存并退出

27:修改权限

chmod 777 /etc/init.d/nginx

28:安装:sysv-rc-conf 并设置开机自启

apt-get install sysv-rc-conf

sysv-rc-conf nginx on

端口占用:sudo fuser -k 80/tcp 切死

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值