table of Contents
One, install Nginx components
The Nginx component is installed on the server where the storage node is located, and the HTTP protocol can be used to directly access the file resources stored in the Storage service;
component version:fastdfs-nginx-module_v1.16.tar.gz
1.1, unzip
[root@localhost temp]# tar -zxf fastdfs-nginx-module_v1.16.tar.gz -C /usr/local/fastdfs
1.2, configuration modification
[root@localhost temp]# cd /usr/local/fastdfs/fastdfs-nginx-module/src
[root@localhost src]# vi /usr/local/fastdfs/fastdfs-nginx-module/src/config
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
To
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/include/fastcommon/"
Second, install Nginx
2.1, installation dependencies
[root@localhost src]# yum install -y gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.2, unzip
[root@localhost temp]# tar -zxf nginx-1.8.0.tar.gz -C /usr/local/fastdfs/
2.3, configuration
cd /usr/local/fastdfs/nginx-1.8.0/
未安装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=/usr/local/fastdfs/fastdfs-nginx-module/src
mkdir -p /var/temp/nginx
make
make install
如果已经安装nginx,则只需添加模块
./configure \
--prefix=/usr/local/nginx \
--add-module=/usr/local/fastdfs/fastdfs-nginx-module/src
make
cp objs/nginx /usr/local/nginx/sbin/nginx
2.4, configuration module
[root@localhost sbin]# cp /usr/local/fastdfs/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@localhost sbin]# cd /etc/fdfs/
[root@localhost fdfs]# vi mod_fastdfs.conf
参考修改项:
connect_timeout=10
tracker_server=192.168.48.128:22122
url_have_group_name = true #Does the URL contain the group name
store_path0=/fastdfs/storage/store
2.5, provide HTTP configuration file
Copy the two configuration files (http.conf and mime.types) in the FastDFS installation package to the /etc/fdfs directory
[root@localhost fdfs]# cp /usr/local/fastdfs/FastDFS/conf/http.conf /etc/fdfs/
[root@localhost fdfs]# cp /usr/local/fastdfs/FastDFS/conf/mime.types /etc/fdfs/
2.6, create a soft connection
nginx starts the soft connection: ln -s /usr/local/lib64/libfdfsclient.so /usr/lib64/libfdfsclient.so
Create a soft connection for network access to the storage service: ln -s /fastdfs/storage/store/data/ /fastdfs/ storage/store/data/M00
2.7, modify Nginx configuration
cd /usr/local/nginx/conf
vi nginx.conf
server{
listen 8888; # storage 配置中,有 http.server_port=8888 的配置信息,必须 一致。配置文件是/etc/fdfs/storaged.conf
server_name localhost;
location ~/group([0-9])/M00{
ngx_fastdfs_module;
}
}
Three, access test
Start nginx, access resources, http://192.168.48.129:8888/group1/M00/00/00/wKgwgV8xbS6AZBBPAADW-MWxcrw515.jpg
make sure port 8888 is open
[root@localhost conf]# firewall-cmd --zone=public --add-port=8888/tcp --permanent
success
[root@localhost conf]# firewall-cmd --reload
success