ubuntu 16.0.4(visualbox虚拟的ubuntu服务器)
fastdfs 5.11
nginx 1.12 实现文件服务器上文件的访问
libfastcommon
https://github.com/happyfish100/libfastcommon/tree/V1.0.36
fastdfs
https://github.com/happyfish100/fastdfs/tree/V5.11
nginx
http://nginx.org/download/nginx-1.12.2.tar.gz
fastdfs-nginx-module
https://github.com/happyfish100/fastdfs-nginx-module
> ./make.sh #编译
> ./make.sh install # 安装
> ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so #创建符号链接
> ./make.sh #编译
> ./make.sh install #安装
> cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
> vi /etc/fdfs/tracker.conf
修改内容:
> base_path=/home/fastdfs
> cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
> vi /etc/fdfs/storage.conf
修改内容:
> base_path=/home/fastdfs
> tracker_server=10.0.2.15:22122
> store_path0=/home/fastdfs
> cp fastdfs-5.11/conf/http.conf /etc/fdfs/
> cp fastdfs-5.11/conf/mime.types /etc/fdfs/
> cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
> vi /etc/fdfs/client.conf
修改内容
> base_path=/home/fastdfs
> tracker_server=10.0.2.15:22122
> include http.conf #打开该行代码 默认是注释掉的
> /etc/init.d/fdfs_trackerd start
其他命令
/etc/init.d/fdfs_trackerd stop #停止
/etc/init.d/fdfs_trackerd restart #重启
> /etc/init.d/fdfs_storaged start
其他命令
/etc/init.d/fdfs_storaged stop #停止
/etc/init.d/fdfs_storaged restart #重启
> ps -aux|grep fdfs
显示内容如下 代表启动成功;如果失败,进入目录/home/fastdfs 查看错误日志信息
root 1543 0.0 0.2 145628 2260 ? Sl 08:50 0:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root 1596 0.0 6.4 82272 65800 ? Sl 08:50 0:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
root 1699 0.0 0.0 14224 968 pts/0 S+ 11:01 0:00 grep --color=auto fdfs
> fdfs_test /etc/fdfs/client.conf upload /home/test.png
This is FastDFS client test program v5.11
Copyright (C) 2008, Happy Fish / YuQing
FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.
[2018-06-08 11:06:33] DEBUG - base_path=/home/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=10.0.2.15, port=23000
group_name=group1, ip_addr=10.0.2.15, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/CgACD1sZ8rmAU861AAAQAPSxqbc399.jpg
source ip address: 10.0.2.15
file timestamp=2018-06-08 11:06:33
file size=4096
file crc32=4105284023
example file url: http://10.0.2.15/group1/M00/00/00/CgACD1sZ8rmAU861AAAQAPSxqbc399.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/CgACD1sZ8rmAU861AAAQAPSxqbc399_big.jpg
source ip address: 10.0.2.15
file timestamp=2018-06-08 11:06:33
file size=4096
file crc32=4105284023
example file url: http://10.0.2.15/group1/M00/00/00/CgACD1sZ8rmAU861AAAQAPSxqbc399_big.jpg
> apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev
> tar -zxvf /home/ubuntu/source/nginx-1.12.2.tar.gz
> cd /home/ubuntu/source/nginx
> ./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src/ # --prefix:安装目录;--add-module:fastdfs-nginx-module文件路径
> make #编译
> make install #安装
> vi /usr/local/nginx/conf/nginx.conf #添加文件服务站点配置
添加内容如下
location /M00 {
root /home/fastdfs/data;
ngx_fastdfs_module;
}
> /usr/local/nginx/sbin/nginx
其他命令
>/usr/local/nginx/sbin/nginx -s stop #停止
>/usr/local/nginx/sbin/nginx -s reload #重新加载配置文件
检查nginx启动情况
> ps -aux|grep nginx
正常情况下信息,如果启动失败,进入/usr/local/nginx/logs/ 目录查看错误信息
root 1607 0.0 0.0 32480 456 ? Ss 08:50 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 1608 0.0 0.3 33060 3372 ? S 08:50 0:00 nginx: worker process
root 1756 0.0 0.1 14224 1088 pts/0 S+ 11:28 0:00 grep --color=auto nginx
访问刚测试上传的图片
http://10.0.2.15/M00/00/00/CgACD1sZ8rmAU861AAAQAPSxqbc399_big.jpg
整个安装过程比较简单,注意好安装的每一个细节.至此安装结束.
我安装是在本机的虚拟机安装。采用的链接模式:网络地址转换(NAT);
这种情况下需要添加端口转发,配置如下:
主机IP | 主机端口 | 子系统IP | 子系统端口 |
---|---|---|---|
本地IP | 22122 | 10.0.2.15 | 22122 |
本地IP | 23000 | 10.0.2.15 | 23000 |
本地IP | 8005 | 10.0.2.15 | 80 |
22122:tracker服务端口
23000:文件上传服务storage端口
80:nginx 文件站点服务端口