1.先了解背景:
FastDFS为什么要结合Nginx以及FastDFS原理,请参考文章:
FastDFS为什么要结合Nginx以及FastDFS原理
2.准备工作:
安装安装Nginx所需的环境,参考文献:Ubuntu 18.04.1安装Nginx
apt install gcc
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g-dev
apt-get install openssl
3.下面介绍安装步骤:
-
解压缩 nginx-1.16.1.tar.gz
-
解压缩 fastdfs-nginx-module-master.zip
-
进入nginx-1.16.1目录中
-
执行
sudo ./configure --prefix=/usr/local/nginx/ --add-module=fastdfs-nginx-module-master解压后的目录的绝对路径/src
sudo make
sudo make install -
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=自己ubuntu虚拟机的ip地址:22122
url_have_group_name=true
store_path0=/home/fxd0/fastdfs/storage -
sudo cp 解压缩的fastdfs-master目录conf目录中的http.conf /etc/fdfs/http.conf
-
sudo cp 解压缩的fastdfs-master目录conf目录中的mime.types /etc/fdfs/mime.types
-
sudo vim /usr/local/nginx/conf/nginx.conf
在http部分中添加配置信息如下:
server {
listen 8888;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
} -
启动nginx
sudo /usr/local/nginx/sbin/nginx