Fastdfs 集成nginx访问 (ubuntu18)

fastdfs安装

依赖

$ sudo apt update
$ sudo apt-get install build-essential
$ sudo apt install libtool

fastfds依赖库

$ git clone https://github.com/happyfish100/libfastcommon.git
$ cd libfastcommon
$ ./make.sh clean && ./make.sh && sudo ./make.sh install

fastfds安装

$ git clone https://github.com/happyfish100/fastdfs.git
$ cd fastdfs
$ ./make.sh clean && ./make.sh && sudo ./make.sh install
$ sudo ./setup.sh /etc/fdfs

配置文件

$ sudo vi /etc/fdfs/tracker.conf

base_path=/home/fds/data # 目录的基路径

$ sudo vi /etc/fdfs/storage.conf

base_path=/home/fds/data # 目录的基路径
store_path0=/home/fds/data # 存储地址
tracker_server: 111.229.xx.xx:22122 # 本机地址
group_name=group1

$ sudo vi /etc/fdfs/client.conf

base_path=/home/fds/data # 目录的基路径
tracker_server: 111.229.xx.xx:22122 # 本机地址

运行服务器

$ sudo /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
$ sudo /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
$ sudo /usr/bin/fdfs_monitor /etc/fdfs/client.conf

测试

$ /usr/bin/fdfs_upload_file /etc/fdfs/client.conf heying.jpg

返回:group1/M00/00/00/b-V5Xl6WzEmAEDBhAFdv5DZyXHk297.jpg

集成nginx

nginx : http://nginx.org/download/nginx-1.15.9.tar.gz
fastdfs-nginx-module: https://github.com/happyfish100/fastdfs-nginx-module

安装依赖

$ sudo apt-get install openssl libpcre3 libpcre3-dev zlib1g-dev

安装nginx

$ unzip fastdfs-nginx-module-master.zip
$ tar -zxvf nginx-1.15.9.tar.gz

$ cd nginx-1.15.9/
$ sudo ./configure --prefix=/usr/local/nginx/ --add-module=/home/fds/tmp/fastdfs-nginx-module-master/src
$ sudo make
$ sudo make install

配置fastdfs模块

$ sudo cp fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
$ sudo vim /etc/fdfs/mod_fastdfs.conf

connect_timeout=10
tracker_server=111.229.xx.xx:22122
url_have_group_name=true
store_path0=/home/fds/data

配置nginx

$ sudo vim /usr/local/nginx/conf/nginx.conf

server {
        listen       8888;
        server_name  localhost;

        location ~/group[0-9]/ {
               ngx_fastdfs_module;
        }

        location / {
            root   html;
            index  index.html index.htm;
        }

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

启动nginx

$ sudo /usr/local/nginx/sbin/nginx

访问地址

http://111.229.xx.xx:8888/group1/M00/00/00/b-V5Xl6W0GWAXtTMAFdv5DZyXHk275.jpg

你可能感兴趣的:(服务器资料)