ubuntu 下 nginx 与 fastDFS 的编译安装
记录一次安装软件的过程
系统信息
OS: Linux Mint 20.2 x86_64 (based on Ubuntu 20.04)
Kernel: 5.4.0-74-generic
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
fastDFS的安装
安装依赖
下载当前最新版依赖
https://github.com/happyfish100/libfastcommon/releases/tag/V1.0.53
fastDFS三端:client tracker storage
fastDFS只有三个功能:上传、下载、删除
配置跟踪服务器
配置跟踪服务器tracker
sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
在/home/(你的用户名)/目录中创建目录:
mkdir -p /home/${USER}/fastdfs/tracker
编辑/etc/fdfs/tracker.conf配置文件
sudo vim /etc/fdfs/tracker.conf
修改 bash_path=/home/(你的用户名)/fastdfs/tracker
配置存储服务器storage
-
创建配置文件
sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
- 在/home/(你的用户名)/fastdfs/ 目录中创建目录 storage
mkdir –p /home/${USER}/fastdfs/storage
-
编辑/etc/fdfs/storage.conf配置文件,并修改内容
-
sudo vim /etc/fdfs/storage.conf
-
base_path=/home/wwo/fastdfs/storage
-
store_path0=/home/wwo/fastdfs/storage1- 注:坑我半天,这样搞不行,简直莫名其妙,换了前缀路径,改成
store_path0=/home/wwo/storage1
后没毛病了
- 注:坑我半天,这样搞不行,简直莫名其妙,换了前缀路径,改成
-
tracker_server=192.168.1.104:22122
- (注:此ip不可以是127.0.0.1,必须是主机ip)
-
-
启动tracker和storage
- 进入到/etc/fdfs/下面执行以下两条指令
sudo fdfs_trackerd /etc/fdfs/tracker.conf
sudo fdfs_storaged /etc/fdfs/storage.conf
测试是否安装成功
-
创建配置文件
sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
-
编辑/etc/fdfs/client.conf配置文件,并修改内容
sudo vim /etc/fdfs/client.conf
base_path=/home/wwo/fastdfs/tracker
tracker_server=192.168.1.104:22122
(注:此ip不可以是127.0.0.1,必须是主机ip) -
上传文件测试
sudo fdfs_upload_file /etc/fdfs/client.conf YOUR_FILE_TO_TEST.xx
如果返回类似group1/M00/00/00/rBIK6VcaP0aARXXvAAHrUgHEviQ394.jpg 的文件id则说明
文件上传成功
nginx与fastdfs-nginx-module的安装
思路:编译安装nginx的时候把fastdfs-nginx-module一起编译安装
-
nginx官网源码下载
https://nginx.org/en/download.html
选择稳定版1.20 -
nginx官网源码安装教程
https://nginx.org/en/docs/configure.html
只配置几个关键参数(代码贴后面) -
ubuntu系统内没有pcre库
下载pcre源码
https://www.linuxfromscratch.org/blfs/view/svn/general/pcre.html
实际代码:
|
|
Configuration summary
- using PCRE library: ../pcre-8.45
- OpenSSL library is not used
- using system zlib library
nginx path prefix: “/usr/local/nginx”
nginx binary file: “/usr/local/nginx/nginx”
nginx modules path: “/home/wwo/Downloads/fastdfs-nginx-module-master/src”
nginx configuration prefix: “/usr/local/nginx”
nginx configuration file: “/usr/local/nginx/nginx.conf”
nginx pid file: “/usr/local/nginx/logs/nginx.pid”
nginx error log file: “/usr/local/nginx/logs/error.log”
nginx http access log file: “/usr/local/nginx/logs/access.log”
nginx http client request body temporary files: “client_body_temp”
nginx http proxy temporary files: “proxy_temp”
nginx http fastcgi temporary files: “fastcgi_temp”
nginx http uwsgi temporary files: “uwsgi_temp”
nginx http scgi temporary files: “scgi_temp”
|
|
|
|
|
|
因为自己用的是最新版本的fdfs与nginx,nginx-module的安装配置最好参考官方文档 https://github.com/happyfish100/fastdfs-nginx-module/blob/master/INSTALL