FastDFS及Nginx的部署
来源:互联网 发布:图片归类整理软件 编辑:程序博客网 时间:2024/06/15 23:27
确保系统已经安装gcc和Perl 安装命令如下
安装gcc环境
[root@localhost ~]# yum install gcc-c++
安装pcre库。
[root@localhost ~]# yum install -y pcre pcre-devel
安装FastDFS之前,先安装libevent工具包。
[root@localhost ~]# yum -y install libevent
将软件放到一个目录中(这里用"/usr/soft")
将FastDFS相关压缩包上传到liunx
libfastcommon-master.tar.gz 下载地址:https://github.com/happyfish100/libfastcommon
fastdfs-nginx-module_v1.16.tar.gz 下载地址:http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
FastDFS_v5.08.tar.gz 下载地址:https://github.com/happyfish100/fastdfs
linux直接下载源码命令(libfastcommon从Windows下载)https://github.com/happyfish100/libfastcommon
wget https://github.com/happyfish100/fastdfs/archive/V5.08.tar.gz
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
wget http://nginx.org/download/nginx-1.10.1.tar.gz
解压 libfastcommon
[root@localhost soft]# tar -zxvf libfastcommon-master.tar.gz
[root@localhost soft]# cd libfastcommon
编译/安装
[root@localhost libfastcommon]# ./make.sh
[root@localhost libfastcommon]# ./make.sh install
将/usr/lib64/libfastcommon.so文件向/usr/lib/下复制一份
[root@localhost libfastcommon]# cp /usr/lib64/libfastcommon.so /usr/lib
解压 FastDFS_v5.08
[root@localhost soft]# tar -zxvf FastDFS_v5.08.tar.gz
[root@localhost soft]# cd FastDFS
编译/安装
[root@localhost FastDFS]# ./make.sh
[root@localhost FastDFS]# ./make.sh install
安装后在/usr/bin/目录下有以fdfs开头的文件都是编译出来的
[root@images-001 bin]# ll /usr/bin/fdfs_*
-rwxr-xr-x. 1 root root 260472 Aug 4 03:08 /usr/bin/fdfs_appender_test
-rwxr-xr-x. 1 root root 260169 Aug 4 03:08 /usr/bin/fdfs_appender_test1
-rwxr-xr-x. 1 root root 250513 Aug 4 03:08 /usr/bin/fdfs_append_file
-rwxr-xr-x. 1 root root 249941 Aug 4 03:08 /usr/bin/fdfs_crc32
-rwxr-xr-x. 1 root root 250596 Aug 4 03:08 /usr/bin/fdfs_delete_file
-rwxr-xr-x. 1 root root 251403 Aug 4 03:08 /usr/bin/fdfs_download_file
-rwxr-xr-x. 1 root root 251161 Aug 4 03:08 /usr/bin/fdfs_file_info
-rwxr-xr-x. 1 root root 266297 Aug 4 03:08 /usr/bin/fdfs_monitor
-rwxr-xr-x. 1 root root 873313 Aug 4 03:08 /usr/bin/fdfs_storaged
-rwxr-xr-x. 1 root root 266840 Aug 4 03:08 /usr/bin/fdfs_test
-rwxr-xr-x. 1 root root 266041 Aug 4 03:08 /usr/bin/fdfs_test1
-rwxr-xr-x. 1 root root 371432 Aug 4 03:08 /usr/bin/fdfs_trackerd
-rwxr-xr-x. 1 root root 251539 Aug 4 03:08 /usr/bin/fdfs_upload_appender
-rwxr-xr-x. 1 root root 252669 Aug 4 03:08 /usr/bin/fdfs_upload_file
配置文件都放到/etc/fdfs文件夹
把FastDFS/conf目录下的所有的配置文件都复制到/etc/fdfs下
[root@localhost FastDFS]# cp /usr/soft/FastDFS_v5.08/conf/* /etc/fdfs
[root@localhost FastDFS]# ll /etc/fdfs
total 108
-rw-r--r--. 1 root root 23981 Aug 4 03:13 anti-steal.jpg
-rw-r--r--. 1 root root 1462 Aug 3 19:54 client.conf
-rw-r--r--. 1 root root 1461 Aug 4 03:08 client.conf.sample
-rw-r--r--. 1 root root 858 Aug 4 03:13 http.conf
-rw-r--r--. 1 root root 31172 Aug 4 03:13 mime.types
-rw-r--r--. 1 root root 3686 Aug 3 20:28 mod_fastdfs.conf
-rw-r--r--. 1 root root 7928 Aug 3 19:48 storage.conf
-rw-r--r--. 1 root root 7927 Aug 4 03:08 storage.conf.sample
-rw-r--r--. 1 root root 105 Aug 4 03:13 storage_ids.conf
-rw-r--r--. 1 root root 7273 Aug 4 07:35 tracker.conf
-rw-r--r--. 1 root root 7200 Aug 4 03:08 tracker.conf.sample
修改所有配置之前在/home下创建repository
再在repository下面创建fastdfs存放图片, 下面配置要用
修改tracker.conf文件
[root@localhost FastDFS]# cd /etc/fdfs
[root@localhost fdfs]# vim tracker.conf
修改以下几项
┌─────────────────────────────────────────────────────────────────────────────────┐
│# bind an address of this host │
│# empty for bind all addresses of this host │
│bind_addr=192.168.58.150 │
│ │
│# the base path to store data and log files │
│base_path=/home/repository/fastdfs (图片上传目录, 可以自定义) │
│ │
│tracker_server=192.168.58.150:22122 【自己的IP】 │
└─────────────────────────────────────────────────────────────────────────────────┘
修改storage.conf文件
[root@localhost FastDFS]# cd /etc/fdfs
[root@localhost fdfs]# vim storage.conf
修改以下几项
┌─────────────────────────────────────────────────────────────────────────────────┐
│group_name=group1 (文件存放的分组名, 可自定义) │
│ │
│# empty for bind all addresses of this host │
│bind_addr=192.168.58.150 │
│ │
│# the base path to store data and log files │
│base_path=/home/repository/fastdfs (图片上传目录, 可以自定义) │
│ │
│# store_path#, based 0, if store_path0 not exists, it's value is base_path │
│# the paths must be exist │
│store_path0=/home/repository/fastdfs │
│ │
│tracker_server=192.168.58.150:22122 【自己的IP】 │
└─────────────────────────────────────────────────────────────────────────────────┘
启动tracker。
[root@localhost fdfs]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
启动storage。
[root@localhost fdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
测试服务 修改配置文件client.conf
[root@localhost fdfs]# vim client.conf
┌─────────────────────────────────────────────────────────────────────────────────┐
│# the base path to store log files │
│base_path=/home/repository/client │
│ │
│# tracker_server can ocur more than once, and tracker_server format is │
│# "host:port", host can be hostname or ip address │
│tracker_server=192.168.58.150:22122 【自己的IP】 │
└─────────────────────────────────────────────────────────────────────────────────┘
测试上传
[root@localhost fdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/anti-steal.jpg
最后一句出现返回地址证明上传成功
example file url:http://192.168.58.150/group1/M00/00/00/wKg6llmWudGAc3fYAABdrZgsqUU812_big.jpg
查看文件
[root@localhost fdfs]# ll /home/repository/fastdfs/data/00/00
看见jpg结尾的证明服务器测试成功
搭建nginx提供http服务。
可以使用官方提供的nginx插件
解压 fastdfs-nginx-module_v1.16.tar.gz
[root@localhost fdfs]# cd /usr/soft
[root@localhost soft]# tar -zxvf libfastcommon-master.tar.gz
将config文件其中的local去掉 这里用【】标注
[root@localhost soft]# cd fastdfs-nginx-module/src
[root@localhost src]# vim config
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ngx_addon_name=ngx_http_fastdfs_module │
│HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module" │
│NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c" │
│CORE_INCS="$CORE_INCS /usr/【local】/include/fastdfs /usr/【local】/include/fastcommon/" │
│CORE_LIBS="$CORE_LIBS -L/usr/local/lib -lfastcommon -lfdfsclient" │
│CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'" │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
安装nginx对nginx进行configure带上以下参数
[root@localhost nginx]# ./configure \
--prefix=/usr/local/nginx \ 【nginx安装位置】
--add-module=/usr/soft/fastdfs-nginx-module/src 【往nginx中添加FastDFS模块】
编译/安装
[root@localhost nginx]# make && make install
将/usr/soft/fastdfs-nginx-module/src/mod_fastdfs.conf文件复制到/etc/fdfs目录下
[root@localhost nginx]# cp /usr/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
编辑mod_fastdfs.conf文件
[root@localhost nginx]# cd /etc/fdfs
[root@localhost fdfs]# vim mod_fastdfs.conf
┌─────────────────────────────────────────────────────────────────────────────────┐
│# the base path to store log files │
│base_path=/tmp 【日志存放路径】 │
│ │
│# FastDFS tracker_server can ocur more than once, and tracker_server format is │
│# "host:port", host can be hostname or ip address │
│# valid only when load_fdfs_parameters_from_tracker is true │
│tracker_server=192.168.58.150:22122 │
│ │
│# the group name of the local storage server │
│group_name=group1 【文件存放分组名, 可自定义】 │
│ │
│# if the url / uri including the group name │
│# set to false when uri like /M00/00/00/xxx │
│# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx │
│# default value is false │
│url_have_group_name = true │
│ │
│# store_path#, based 0, if store_path0 not exists, it's value is base_path │
│# the paths must be exist │
│# must same as storage.conf │
│store_path0=/home/repository/fastdfs │
└─────────────────────────────────────────────────────────────────────────────────┘
nginx配置
[root@localhost fdfs]# cd /usr/local/nginx/conf
[root@localhost conf]# vim nginx.conf
┌─────────────────────────────────────────────────────────────────────────────────┐
│server { │
│ listen 80; │
│ server_name 192.168.58.150; │
│ │
│ #charset koi8-r; │
│ │
│ #access_log logs/host.access.log main; │
│ │
│ location /group1/M00/ { 【正则匹配】 │
│ root /home/repository/fastdfs/data; │
│ ngx_fastdfs_module; │
│ } │
│} │
└─────────────────────────────────────────────────────────────────────────────────┘
安装gcc环境
[root@localhost ~]# yum install gcc-c++
安装pcre库。
[root@localhost ~]# yum install -y pcre pcre-devel
安装FastDFS之前,先安装libevent工具包。
[root@localhost ~]# yum -y install libevent
将软件放到一个目录中(这里用"/usr/soft")
将FastDFS相关压缩包上传到liunx
libfastcommon-master.tar.gz 下载地址:https://github.com/happyfish100/libfastcommon
fastdfs-nginx-module_v1.16.tar.gz 下载地址:http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
FastDFS_v5.08.tar.gz 下载地址:https://github.com/happyfish100/fastdfs
linux直接下载源码命令(libfastcommon从Windows下载)https://github.com/happyfish100/libfastcommon
wget https://github.com/happyfish100/fastdfs/archive/V5.08.tar.gz
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
wget http://nginx.org/download/nginx-1.10.1.tar.gz
解压 libfastcommon
[root@localhost soft]# tar -zxvf libfastcommon-master.tar.gz
[root@localhost soft]# cd libfastcommon
编译/安装
[root@localhost libfastcommon]# ./make.sh
[root@localhost libfastcommon]# ./make.sh install
将/usr/lib64/libfastcommon.so文件向/usr/lib/下复制一份
[root@localhost libfastcommon]# cp /usr/lib64/libfastcommon.so /usr/lib
解压 FastDFS_v5.08
[root@localhost soft]# tar -zxvf FastDFS_v5.08.tar.gz
[root@localhost soft]# cd FastDFS
编译/安装
[root@localhost FastDFS]# ./make.sh
[root@localhost FastDFS]# ./make.sh install
安装后在/usr/bin/目录下有以fdfs开头的文件都是编译出来的
[root@images-001 bin]# ll /usr/bin/fdfs_*
-rwxr-xr-x. 1 root root 260472 Aug 4 03:08 /usr/bin/fdfs_appender_test
-rwxr-xr-x. 1 root root 260169 Aug 4 03:08 /usr/bin/fdfs_appender_test1
-rwxr-xr-x. 1 root root 250513 Aug 4 03:08 /usr/bin/fdfs_append_file
-rwxr-xr-x. 1 root root 249941 Aug 4 03:08 /usr/bin/fdfs_crc32
-rwxr-xr-x. 1 root root 250596 Aug 4 03:08 /usr/bin/fdfs_delete_file
-rwxr-xr-x. 1 root root 251403 Aug 4 03:08 /usr/bin/fdfs_download_file
-rwxr-xr-x. 1 root root 251161 Aug 4 03:08 /usr/bin/fdfs_file_info
-rwxr-xr-x. 1 root root 266297 Aug 4 03:08 /usr/bin/fdfs_monitor
-rwxr-xr-x. 1 root root 873313 Aug 4 03:08 /usr/bin/fdfs_storaged
-rwxr-xr-x. 1 root root 266840 Aug 4 03:08 /usr/bin/fdfs_test
-rwxr-xr-x. 1 root root 266041 Aug 4 03:08 /usr/bin/fdfs_test1
-rwxr-xr-x. 1 root root 371432 Aug 4 03:08 /usr/bin/fdfs_trackerd
-rwxr-xr-x. 1 root root 251539 Aug 4 03:08 /usr/bin/fdfs_upload_appender
-rwxr-xr-x. 1 root root 252669 Aug 4 03:08 /usr/bin/fdfs_upload_file
配置文件都放到/etc/fdfs文件夹
把FastDFS/conf目录下的所有的配置文件都复制到/etc/fdfs下
[root@localhost FastDFS]# cp /usr/soft/FastDFS_v5.08/conf/* /etc/fdfs
[root@localhost FastDFS]# ll /etc/fdfs
total 108
-rw-r--r--. 1 root root 23981 Aug 4 03:13 anti-steal.jpg
-rw-r--r--. 1 root root 1462 Aug 3 19:54 client.conf
-rw-r--r--. 1 root root 1461 Aug 4 03:08 client.conf.sample
-rw-r--r--. 1 root root 858 Aug 4 03:13 http.conf
-rw-r--r--. 1 root root 31172 Aug 4 03:13 mime.types
-rw-r--r--. 1 root root 3686 Aug 3 20:28 mod_fastdfs.conf
-rw-r--r--. 1 root root 7928 Aug 3 19:48 storage.conf
-rw-r--r--. 1 root root 7927 Aug 4 03:08 storage.conf.sample
-rw-r--r--. 1 root root 105 Aug 4 03:13 storage_ids.conf
-rw-r--r--. 1 root root 7273 Aug 4 07:35 tracker.conf
-rw-r--r--. 1 root root 7200 Aug 4 03:08 tracker.conf.sample
修改所有配置之前在/home下创建repository
再在repository下面创建fastdfs存放图片, 下面配置要用
修改tracker.conf文件
[root@localhost FastDFS]# cd /etc/fdfs
[root@localhost fdfs]# vim tracker.conf
修改以下几项
┌─────────────────────────────────────────────────────────────────────────────────┐
│# bind an address of this host │
│# empty for bind all addresses of this host │
│bind_addr=192.168.58.150 │
│ │
│# the base path to store data and log files │
│base_path=/home/repository/fastdfs (图片上传目录, 可以自定义) │
│ │
│tracker_server=192.168.58.150:22122 【自己的IP】 │
└─────────────────────────────────────────────────────────────────────────────────┘
修改storage.conf文件
[root@localhost FastDFS]# cd /etc/fdfs
[root@localhost fdfs]# vim storage.conf
修改以下几项
┌─────────────────────────────────────────────────────────────────────────────────┐
│group_name=group1 (文件存放的分组名, 可自定义) │
│ │
│# empty for bind all addresses of this host │
│bind_addr=192.168.58.150 │
│ │
│# the base path to store data and log files │
│base_path=/home/repository/fastdfs (图片上传目录, 可以自定义) │
│ │
│# store_path#, based 0, if store_path0 not exists, it's value is base_path │
│# the paths must be exist │
│store_path0=/home/repository/fastdfs │
│ │
│tracker_server=192.168.58.150:22122 【自己的IP】 │
└─────────────────────────────────────────────────────────────────────────────────┘
启动tracker。
[root@localhost fdfs]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
启动storage。
[root@localhost fdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
测试服务 修改配置文件client.conf
[root@localhost fdfs]# vim client.conf
┌─────────────────────────────────────────────────────────────────────────────────┐
│# the base path to store log files │
│base_path=/home/repository/client │
│ │
│# tracker_server can ocur more than once, and tracker_server format is │
│# "host:port", host can be hostname or ip address │
│tracker_server=192.168.58.150:22122 【自己的IP】 │
└─────────────────────────────────────────────────────────────────────────────────┘
测试上传
[root@localhost fdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/anti-steal.jpg
最后一句出现返回地址证明上传成功
example file url:http://192.168.58.150/group1/M00/00/00/wKg6llmWudGAc3fYAABdrZgsqUU812_big.jpg
查看文件
[root@localhost fdfs]# ll /home/repository/fastdfs/data/00/00
看见jpg结尾的证明服务器测试成功
搭建nginx提供http服务。
可以使用官方提供的nginx插件
解压 fastdfs-nginx-module_v1.16.tar.gz
[root@localhost fdfs]# cd /usr/soft
[root@localhost soft]# tar -zxvf libfastcommon-master.tar.gz
将config文件其中的local去掉 这里用【】标注
[root@localhost soft]# cd fastdfs-nginx-module/src
[root@localhost src]# vim config
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ngx_addon_name=ngx_http_fastdfs_module │
│HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module" │
│NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c" │
│CORE_INCS="$CORE_INCS /usr/【local】/include/fastdfs /usr/【local】/include/fastcommon/" │
│CORE_LIBS="$CORE_LIBS -L/usr/local/lib -lfastcommon -lfdfsclient" │
│CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'" │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
安装nginx对nginx进行configure带上以下参数
[root@localhost nginx]# ./configure \
--prefix=/usr/local/nginx \ 【nginx安装位置】
--add-module=/usr/soft/fastdfs-nginx-module/src 【往nginx中添加FastDFS模块】
编译/安装
[root@localhost nginx]# make && make install
将/usr/soft/fastdfs-nginx-module/src/mod_fastdfs.conf文件复制到/etc/fdfs目录下
[root@localhost nginx]# cp /usr/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
编辑mod_fastdfs.conf文件
[root@localhost nginx]# cd /etc/fdfs
[root@localhost fdfs]# vim mod_fastdfs.conf
┌─────────────────────────────────────────────────────────────────────────────────┐
│# the base path to store log files │
│base_path=/tmp 【日志存放路径】 │
│ │
│# FastDFS tracker_server can ocur more than once, and tracker_server format is │
│# "host:port", host can be hostname or ip address │
│# valid only when load_fdfs_parameters_from_tracker is true │
│tracker_server=192.168.58.150:22122 │
│ │
│# the group name of the local storage server │
│group_name=group1 【文件存放分组名, 可自定义】 │
│ │
│# if the url / uri including the group name │
│# set to false when uri like /M00/00/00/xxx │
│# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx │
│# default value is false │
│url_have_group_name = true │
│ │
│# store_path#, based 0, if store_path0 not exists, it's value is base_path │
│# the paths must be exist │
│# must same as storage.conf │
│store_path0=/home/repository/fastdfs │
└─────────────────────────────────────────────────────────────────────────────────┘
nginx配置
[root@localhost fdfs]# cd /usr/local/nginx/conf
[root@localhost conf]# vim nginx.conf
┌─────────────────────────────────────────────────────────────────────────────────┐
│server { │
│ listen 80; │
│ server_name 192.168.58.150; │
│ │
│ #charset koi8-r; │
│ │
│ #access_log logs/host.access.log main; │
│ │
│ location /group1/M00/ { 【正则匹配】 │
│ root /home/repository/fastdfs/data; │
│ ngx_fastdfs_module; │
│ } │
│} │
└─────────────────────────────────────────────────────────────────────────────────┘
阅读全文
0 0
- FastDFS及Nginx的部署
- fastdfs + nginx 安装部署
- FastDFS + nginx 单点部署
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- 转载:FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- fastDfs安装及启动+nginx
- FastDFS与Nginx的搭建及遇到的问题
- [置顶]FastDFS+Nginx(单点部署)事例
- 01FastDFS的安装部署
- FastDFS+nginx的安装配置
- nginx + FastDFS分布式文件服务器搭建及配置
- Nginx的配置与部署及例子
- Linux下nginx的安装及部署
- Nginx + FastDFS
- 关于 axios-mock-adapter 调用流程的分析
- 分享:CSS3用transition实现边框动画效果
- linux下交叉编译libusb的方法及编译一个使用了libusb库的test程序的方法
- Exchange 用户发送邮件提示:您无权执行此操作,解决办法
- 使用POI读取excel文件内容
- FastDFS及Nginx的部署
- curl中对应cookie的管理
- javascript 浏览器永久保存数据:localStorage
- log4j:WARN custom level class not found问题解决方法
- 欢迎使用CSDN-markdown编辑器
- js杂记
- 图像升采样的实现详解
- LeetCode 485 最大连续1的个数
- java RC4加密解密