cd /opt
sudo tar -xvf fastdfs-6.06.tar.gz
cd fastdfs-6.06
sudo ./make.sh
sudo ./make.sh install
ls -l /etc/init.d/ | grep fdfs
cd /etc/fdfs
ls -l
tarcker.conf.sample
是tracker的配置文件模板storage.conf.sample
是storage的配置文件模板client.conf.sample
是客户端的配置文件模板sudo cp tracker.conf.sample tracker.conf
sudo vim tracker.conf
tracker.conf
,修改base_path
配置:base_path=/home/fdfs/tracker/log # tracker的数据和日志存放目录
刚刚配置的目录可能不存在,我们创建出来
sudo mkdir -p /home/fdfs/tracker/log
启动tracker
我们可以使用 sh /etc/init.d/fdfs_trackerd
启动,不过安装过程中,fdfs已经被设置为系统服务,我们可以采用熟悉的服务启动方式:
sudo service fdfs_trackerd start # 启动fdfs_trackerd服务,停止用stop
首先我们将模板文件进行赋值和重命名:
sudo cp storage.conf.sample storage.conf
sudo vim storage.conf
打开storage.conf
,修改base_path
配置:
base_path=/home/fdfs/storage/log # storage的数据和日志存放目录
store_path0=/home/fdfs/storage # storage的上传文件存放路径
# tracker的地址,ip为本机ip,请不要使用127.0.0.1,尽量设置本机为静态ip
tracker_server=192.168.183.130:22122
刚刚配置的目录可能不存在,我们创建出来
sudo mkdir -p /home/fdfs/storage/log
启动storage
我们可以使用 sh /etc/init.d/fdfs_storaged
启动,同样我们可以用服务启动方式:
sudo service fdfs_storaged start # 启动fdfs_storaged服务,停止用stop
sudo cp client.conf.sample client.conf
sudo vim client.conf
base_path=/home/fdfs/tracker/log //log日志
tracker_server=192.168.183.130:22122 //tracker服务器IP地址和端口号
http.tracker_server_port=8080 # tracker服务器的http端口号,必须和tracker的设置对应起来
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf ~/if_brother_3231124.png
测试上传 加载配置文件 随便找个测试文件
sudo unzip fastdfs-nginx-module-master.zip
# 进入配置目录
cd /opt/fastdfs-nginx-module-master/src/
# 修改配置
sudo vim config
# 执行下面命令(将配置中的/usr/local改为/usr):
:%s+/usr/local/+/usr/+g
# 将src目录下的mod_fastdfs.conf复制到 /etc/fdfs目录:
sudo cp mod_fastdfs.conf /etc/fdfs/
# 编辑该文件
sudo vim /etc/fdfs/mod_fastdfs.cof
connect_timeout=10 # 客户端访问文件连接超时时长(单位:秒)
tracker_server=192.168.183.130:22122 # tracker服务IP和端口
url_have_group_name=true # 访问链接前缀加上组名
store_path0=/home/fdfs/storage # 文件存储路径,与storage.conf中的 store_path0保持一致
cd /opt/fastdfs-6.06/conf
cp http.conf mime.types /etc/fdfs/
/usr/sbin/nginx -V
cd /opt
tar -xvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
# 加上你已有的模块,和想要添加的模块
sudo ./configure \
--with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-GkiujU/nginx-1.14.0=. -fstack-
protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -
D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -
fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-
path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-
path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-
path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-
fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --
http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --
with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --
with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-
http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --
with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module
--with-http_image_filter_module=dynamic --with-http_sub_module --with-
http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-
mail=dynamic --with-mail_ssl_module \ #之前已有
--add-module=/opt/fastdfs-nginx-module-master/src #后来添加,记住是src目录
sudo apt-get install libxml2 libxml2-dev libxslt-dev
– the HTTP image filter module requires the GD library.
sudo apt-get install libgd2-xpm libgd2-xpm-dev
– the GeoIP module requires the GeoIP library.
sudo apt-get install geoip-database libgeoip-dev
– the HTTP rewrite module requires the PCRE library.
sudo apt-get install libpcre3 libpcre3-dev
sudo make
cp /usr/sbin/nginx /usr/sbin/nginx.bak #备份
cp ./objs/nginx /usr/local/nginx/sbin/ #make编译过后的nginx,替换系统安装
sudo vim /etc/nginx/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# 添加
# 监听域名中带有group的,交给FastDFS模块处理
location ~/group([0-9])/ {
ngx_fastdfs_module;
}
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
service nginx start