centos7在单台服务器上安装FastDFS的方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7在单台服务器上安装FastDFS的方法相关的知识,希望对你有一定的参考价值。

准备环境:

#安装依赖包

yum -y install gcc gcc-c++ libtool pcre* zlib openssl openssl-devel

mkdir /FastDFS/

#上传下载工具

yum -y install lrzsz

yum -y install unzip

cd /FastDFS/

上传fastdfs-dep.zip

rz

#安装libfastcommon

cd /FastDFS/

unzip fastdfs-dep.zip

cd /FastDFS/fastdfs-dep/

unzip libfastcommon-1.0.7.zip

cd libfastcommon-1.0.7

./make.sh

./make.sh install

#安装Fastdfs

cd /FastDFS/fastdfs-dep

tar -zxvf  FastDFS_v5.05.tar.gz

cd /FastDFS/fastdfs-dep/FastDFS

sed -i ‘62cTARGET_CONF_PATH=/usr/local/FastDFS‘ /FastDFS/fastdfs-depFastDFS/make.sh

./make.sh

./make.sh install

#Fastdfs进行配置

mkdir  /FastDFS/fastdfs_tracker

mkdir  /FastDFS/fastdfs_client

cp -r /FastDFS/fastdfs-dep/FastDFS/conf/*  /etc/fdfs/

sed -i ‘22cbase_path=/FastDFS/fastdfs_tracker‘  /etc/fdfs/tracker.conf

sed -i ‘41cstore_lookup=0‘ /etc/fdfs/tracker.conf

sed -i ‘10cbase_path=/FastDFS/fastdfs_client‘ /etc/fdfs/client.conf

sed -i "14ctracker_server=101.200.80.17:22122"   /etc/fdfs/client.conf

#关防火墙

systemctl stop firewalld.service >/dev/null

#启动Fastdfs

fdfs_trackerd /etc/fdfs/tracker.conf

echo ‘fdfs_trackerd /etc/fdfs/tracker.conf‘ >>/etc/rc.d/rc.local

#Fastdfs进行配置

mkdir  /FastDFS/fastdfs_storage_info

mkdir  /FastDFS/fastdfs_storage_data

#组名

sed -i ‘11cgroup_name=group1‘ /etc/fdfs/storage.conf

sed -i ‘41cbase_path=/FastDFS/fastdfs_storage_info‘ /etc/fdfs/storage.conf

sed -i ‘109cstore_path0=/FastDFS/fastdfs_storage_data‘ /etc/fdfs/storage.conf

#输入tracker服务器的ip地址

sed -i "118ctracker_server=101.200.80.17:22122" /etc/fdfs/storage.conf

#关防火墙

systemctl stop firewalld.service >/dev/null

#启动Fastdfs

fdfs_storaged /etc/fdfs/storage.conf >/dev/null

echo ‘fdfs_storaged /etc/fdfs/storage.conf‘ >>/etc/rc.d/rc.local

 

 

 

#解压nginx模块

cd  /FastDFS/fastdfs-dep/

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz >/dev/null

sed -i   ‘4cCORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon"‘ /FastDFS/fastdfs-dep/fastdfs-nginx-module/src/config

 

#安装Nginx模块

cd /FastDFS/fastdfs-dep/

tar -zxvf nginx-1.7.8.tar.gz

cd nginx-1.7.8

./configure --prefix=/usr/local/nginx  --add-module=/FastDFS/fastdfs-dep/fastdfs-nginx-module/src >/dev/null

make

make install

#Nginx进行配置

sed -i ‘1cuser  root   root;‘ /usr/local/nginx/conf/nginx.conf

sed -i ‘43c\   location /group1/M00 \{‘ /usr/local/nginx/conf/nginx.conf

sed -i ‘44c\   root /FastDFS/fastdfs_storage_data;‘ /usr/local/nginx/conf/nginx.conf

sed -i ‘45c\   ngx_fastdfs_module;‘  /usr/local/nginx/conf/nginx.conf

#配置/etc/fdfs/mod_fastdfs.conf

cp -R /FastDFS/fastdfs-dep/fastdfs-nginx-module/src/mod_fastdfs.conf  /etc/fdfs/

sed -i ‘47cgroup_name=group1‘ /etc/fdfs/mod_fastdfs.conf

sed -i ‘53curl_have_group_name=true‘ /etc/fdfs/mod_fastdfs.conf

sed -i ‘62cstore_path0=/FastDFS/fastdfs_storage_data‘ /etc/fdfs/mod_fastdfs.conf

sed -i "40ctracker_server=101.200.80.17:22122"  /etc/fdfs/mod_fastdfs.conf

 

 

需要添加的内容如下:

cd  /usr/local/nginx/conf/

vi  nginx.conf

 

#gzip  on;

34

    #  upstream server_group0 {

    #    server 192.168.115.179:80;

    #    server 192.168.115.180:80;

    # }

    upstream server_group1 {

        server 192.168.115.181:80;

    }

//编者友情提示:192.168.115.179192.168.115.180属于group0组,192.168.115.181属于group1

//因为是单台服务器所有就留下了一个组,这个组里只有一个服务器。其他的注释掉了。如果建立fastDFS集群可以参考。

    server {

        listen       80;

        server_name  localhost;

 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;


    location /group0 {

       #     proxy_set_header Host $host;

       #     proxy_set_header X-Real-IP $remote_addr;

       #     proxy_set_header X-Forwrded-For $proxy_add_x_forwarded_for;

       #    proxy_pass  http://server_group0;

      # }

        location /group1 {

            proxy_redirect off;

            proxy_set_header Host $host;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass  http://server_group1;

        }

 

 

启动nginx:

/usr/local/nginx/sbin/nginx

重新启动nginx

/usr/local/nginx/sbin/nginx  -s  reload

vi /etc/rc.d/rc.local

将运行命令行添加进文件 /usr/local/nginx/sbin/nginx

 

 


本文出自 “HIBIKI的技术工坊” 博客,请务必保留此出处http://hibiki.blog.51cto.com/12625187/1922602

以上是关于centos7在单台服务器上安装FastDFS的方法的主要内容,如果未能解决你的问题,请参考以下文章

在单台主机上配置LNMP

如何在单台机器上管理/组合多台服务器?

是否可以在单台计算机上为 Atlassian Bamboo 安装多个远程代理?

在单台服务器上搭建elasticsearch集群

在CentOS7上使用FastDFS搭建文件服务器

Centos7 上安装 FastDFS