FastDFS+nginx安装与配置
FastDFS 是一个由 C 语言实现的开源轻量级分布式文件系统
环境 centos7
安装gcc yum install gcc-c++ -y
2.libevent
yum -y install libevent
如果没有perl库,需要使用yum install perl* 命令安装一下
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
3.安装libfastcommon
上传压缩包文件libfastcommonV1.0.7.tar.gz 到 /usr/local目录下,并解压。
tar -zxvf libfastcommonV1.0.7.tar.gz
编译 ./make.sh
安装 ./make.sh install
libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下
cp /usr/lib64/libfastcommon.so /usr/lib/
安装 tracker
安装FastDFS_v5.05.tar.gz到 /opt
tar -zxvf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh
./make.sh install
安装成功之后,将安装目录下的conf下的文件拷贝到/etc/fdfs/下。
cd conf
cp * /etc/fdfs/
vim /etc/fdfs/client.conf
base_path=/opt/fastdfs
tracker_server=192.168.239.139:22122
修改配置文件
vim /etc/fdfs/tracker.conf
base_path=/opt/fastdfs
mkdir /opt/fastdfs
启动 tracker
fdfs_trackerd /etc/fdfs/tracker.conf start
FastDFS—storage配置
vim /etc/fdfs/storage.conf
base_path=/opt/fastdfs
store_path0=/opt/fastdfs/fdfs_storage
tracker_server=192.168.239.139:22122
mkdir /opt/fastdfs/fdfs_storage
启动 storage
fdfs_storaged /etc/fdfs/storage.conf start
FastDFS整合nginx
插件配置
cd /opt
上传fastdfs-nginx-module_v1.16.tar.gz
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
1.vi fastdfs-nginx-module/src/config
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
2. 将FastDFS-nginx-module/src下的mod_fastdfs.conf拷贝至/etc/fdfs/下
[root@localhost src]# cp mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
base_path=/opt/fastdfs
tracker_server=192.168.239.139:22122
url_have_group_name = true
store_path0=/opt/fastdfs/fdfs_storage
nginx安装
./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=/opt/fastdfs-nginx-module/src
2.修改nginx配置文件
Vi /nginx/conf/nginx.conf
server_name 192.168.239.139
location /group1/M00/ {
ngx_fastdfs_module;
}
3.mkdir -p /var/temp/nginx/client 创建nginx/client目录
cd sbin
./nginx
上传测试
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/abc.jpg