网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

FastDFS+Nginx单机部署-创新互联


一、环境

创新互联建站专注于企业成都全网营销推广、网站重做改版、勃利网站定制设计、自适应品牌网站建设、H5页面制作商城网站建设、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为勃利等各大城市提供网站开发制作服务。

   Ubuntu 18.04.1 LTS

二、资源准备

1. nginx-1.14.0

2. FastDFS-5.11

3. fastdfs-nginx-module

4. libfastcommon

三、安装

   1.安装libfastcommon

      1>解压libfastcommon

      2>make命令编译

      3>make install命令安装

      4>设置软链接

      ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
      ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
      ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
      ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

   2.安装FastDFS

      1>解压

      2>make命令编译,make install命令安装

      3>将安装到/etc/fdfs/下的三个示例配置文件复制一份,去掉.sample后缀

   3.配置Tracker

      1>在/opt/下建立f_tracker目录

      2>修改2.3>中的tracker.conf文件

         disabled=false#启用配置文件(false为启用)
         port=22122#设置tracker的端口号,通常采用22122这个默认端口
         base_path=/opt/f_tracker#设置tracker的数据文件和日志目录
         http.server_port=6666#设置http端口号,默认为8080

3>为启动脚本创建软引用,因为fdfs_trackerd等命令在/usr/local/bin中并没有,而是在/usr/bin路径下

         ln -s /usr/bin/fdfs_trackerd /usr/local/bin
         ln -s /usr/bin/stop.sh /usr/local/bin
         ln -s /usr/bin/restart.sh /usr/local/bin

4>service fdfs_trackerd start启动Tracker服务器(通过netstat -unltp|grep fdfs 命令查看tracker服务的监听情况)

   4.配置Storage

      1>在/opt/下建立f_storage和f_storage_data目录

      2>修改2.3>中的storage.conf文件

      disabled=false#启用配置文件(false为启用)
      group_name=group1#组名,根据实际情况修改
      port=23000 #设置storage的端口号,默认是23000,同一个组的storage端口号必须 一致
      base_path=/opt/f_storage#设置storage数据文件和日志目录
      store_path_count=1 #存储路径个数,需要和store_path个数匹配
      store_path0=/opt/f_storage_data #实际文件存储路径
      tracker_server=192.168.43.45:22122 #tracker 服务器的 IP地址和端口号,因为本次是单机搭建,所以此处为本机ip,集群搭建的话即填写tracker服务器所在的ip
      http.server_port=8888#设置 http 端口号

      3>为Storage服务器的启动脚本设置软引用

       ln -s /usr/bin/fdfs_storaged /usr/local/bin

      4>service fdfs_storaged start命令启动Storage服务器,文件存储路径下会生成多级存储目录即为成功

      5>查看storage是否登记在tracker上。命令/usr/bin/fdfs_monitor /etc/fdfs/storage.conf 有图中Active字样为成功

FastDFS+Nginx单机部署

   5.配置client.conf

      1>修改2.3>中的storage.conf文件

       base_path=/opt/fastdfs_tracker#tracker服务器文件路径
       tracker_server=192.168.43.45:22122#tracker服务器IP地址和端口号
     http.tracker_server_port=6666# tracker 服务器的 http 端口号,必须和tracker的设置对应起来

      2>通过命令上传1.txt

       /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /home/2.jpg

      3>成功则返回id为group1/M00/00/00/wKgrLVu5nQ6ADqBpAAB92gKP0_o908.jpg

   6.安装Nginx

      1>解压nginx-1.14.0和fastdfs-nginx-module

      2>为nginx添加fastdfs-nginx-module模块。在nginx-1.14.0目录下输入命令./configure --prefix=/usr/share/nginx --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=/home/jobs/fastdfs/moudle1/src

--prefix为安装目录,/home/jobs/fastdfs/moudle1/src为模块所在目录

      3>make命令编译

      4>make install命令安装

      5>我安装时编译一直不通过,弄了大半天也没通过,最后我是先通过apt-get install nginx安装nginx,然后nognx -V命令查看安装信息,得知--prefix=/usr/share/nginx --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,然后在nginx-1.14.0目录下输入命令./configure加以上信息加--add-module=/home/jobs/fastdfs/moudle1/src 最终编译成功。

   7.配置fastdfs-nginx-module模块和nginx

      1>修改/usr/share/nginx/nginx.conf

          server {

       listen      8888;

       server_name localhost;

       #charset koi8-r;

       #access_log logs/host.access.log main;

       location / {

           root  html;

           index index.html index.htm;

       }

   location ~/group1/M00 {

         ngx_fastdfs_module;

   }

       #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;

       }

       # proxy the PHP scripts to Apache listening on 127.0.0.1:80

       #

       #location ~ \.php$ {

       #   proxy_pass  http://127.0.0.1;

       #}

       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

       #

       #location ~ \.php$ {

       #   root          html;

       #   fastcgi_pass  127.0.0.1:9000;

       #   fastcgi_index index.php;

       #   fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

       #   include       fastcgi_params;

       #}

       # deny access to .htaccess files, if Apache's document root

       # concurs with nginx's one

       #

       #location ~ /\.ht {

       #   deny all;

       #}

   }

      2>进入FastDFS安装包的目录下的conf目录,将http.conf和mime.types拷贝到/etc/fdfs目录下,接下来还需要把fastdfs-nginx-module安装目录中src目录下的mod_fastdfs.conf也拷贝到/etc/fdfs目录下:

      3>mod_fastdfs.conf修改如下配置,其它默认

#连接超时时间

connect_timeout=10

# Tracker Server

tracker_server=file.ljzsg.com:22122

# StorageServer默认端口

storage_server_port=23000

#如果文件ID的uri中包含/group**,则要设置为true

url_have_group_name = true

# Storage配置的store_path0路径,必须和storage.conf中的一致

store_path0=/opt/f_storage_data

      4>启动Nginx 命令service nginx start,打印出pid信息为成功

      5>浏览器访问http://192.168.43.45:8888/group1/M00/00/00/wKgrLVu5nQ6ADqBpAAB92gKP0_o908.jpg

 FastDFS+Nginx单机部署

四、集群安装

   集群安装只需要在每台机器上安装fastdfs和nginx,如果是一台tracker,多台storage,只要在一台机器上配置tracker,其他机器上配置storage和nginx即可。Fastdfs也可以有多台tracker组成,每台tracker地位相同,轮查使用,storage可以按组划分,每个group内的storage的内容相同。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享标题:FastDFS+Nginx单机部署-创新互联
当前网址:http://bjjierui.cn/article/ccsdoi.html

其他资讯