Centos7单台服务器搭建FastDFS+Nginx

  • 来源:网络
  • 更新日期:2020-06-29

摘要:建站服务器 Fastdfs+Nginx配置操作单台配置安装包下载:wget https://github.com/happyfish200/libfastcommon/archive/V1.0.7.tar.gzwget

建站服务器

Fastdfs+Nginx配置操作

单台配置

安装包下载:

wget https://github.com/happyfish200/libfastcommon/archive/V1.0.7.tar.gz

wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz

wget https://github.com/happyfish200/fastdfs/archive/V5.05.tar.gz

wget http://nginx.org/download/nginx-1.8.0.tar.gz

(备注:centos7里面Nginx的依赖包是最新的可以yum直接下载安装:yum install zlib*  pcre* -y)

1.libfastcommon安装;

mkdir -pv /usr/fastdfs

tar -zxvf V1.0.7.tar.gz -C /usr/fastdfs/

cd /usr/fastdfs/libfastcommon-1.0.7

./make.sh

./make.sh install

2.安装Fastdfs;

tar -zxvf V5.05.tar.gz -C /usr/fastdfs/

cd /usr/fastdfs/fastdfs-5.05

(备注:在这个目录下解压的文件下面不用做链接)

./make.sh

./make.sh install

3.配置tracker和storage

cp conf/* /etc/fdfs/

(备注:FastDFS启动文件默认在/usr/bin/,配置文件在/etc/fdfs下)

mkdir -pv /data/fastdfs/tracker

mkdir -pv /data/fastdfs/storage

(备注:以上创建的是存放目录)

cd /etc/fdfs

vim tracker.conf

暂时修改下面一项即可

base_path=/data/fastdfs/tracker

vim storage.conf

修改内容:

base_path=/data/fastdfs/storage

store_path0=/data/fastdfs/storage

tracker_server=本地IP地址:22122 

http.server_port=8888

4.关闭防火墙,启动tracker和storage

systemctl stop firewalld.service

/usr/bin/fdfs_tracker /etc/fdfs/tracker start

/usr/bin/fdfs_storage /etc/fdfs/storage start

5.验证是否启动

ps -ef | grep fdfs

6.安装fastdfs-nginx-module

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz -C /usr/local/

cd /usr/local/fastdfs-nginx-module/src

vim config

去掉local目录层

CORE_INCS=$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/

cp mod_fastdfs.conf /etc/fdfs

vim /etc/fdfs/mod_fastdfs.conf

修改以下内容;

connect_timeout=10

tracker_server=本地IP地址:22122

url_have_group_name = true

store_path0=/data/fastdfs/storage

7.装Nginx

cd 

tar -zxvf nginx-1.8.0.tar.gz

cd nginx-1.8.0/

./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src/

make

make install

vim /usr/local/nginx/conf/nginx.conf

在server 里面添加以下内容

location ~/group1/M00{

root /data/fastdfs/storage/data;

ngx_fastdfs_module;

}

做个软连接ln -s /data/fastdfs/storage/data //data/fastdfs/storage/data/M00

监听端口:

listen 8888

(备注:nginx里的端口要和配置FastDFS存储中的storage.conf文件配置一致)

最后启动Nginx上传验证


两台服务器可以把tracker和storage分开  nginx和storage一台或者都安装分成两个组group


新网虚拟主机