安装fastdfs-nginx-module

安装fastdfs-nginx-module
  1. 解压缩 nginx-1.8.1.tar.gz

  2. 解压缩 fastdfs-nginx-module-master.zip

  3. 进入nginx-1.8.1目录中

  4. 执行

    sudo ./configure  --prefix=/usr/local/nginx/ --add-module=fastdfs-nginx-module-master的解压后的目录的绝对路径/src
    

    注意:这时候会报一个错,说没有PCRE库

    下载缺少的库

    sudo apt-get install libpcre3 libpcre3-dev 
    
    • 首先你需要去更换源,因为ubuntu自带的源没有这个库

    • 更换下载源为阿里的源

    • 先把原来的源文件备份

      sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
      
    • 编辑源文件

      sudo vim /etc/apt/sources.list
      

      把原来的内容全部删掉,粘贴一下内容:

      deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
       
      deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
       
      deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
       
      deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
       
      deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
      

      更换完源之后执行

      sudo apt-get  update
      sudo apt-get install libpcre3 libpcre3-dev
      

      然后进入nginx-1.8.1目录中,再次执行:

      sudo ./configure  --prefix=/usr/local/nginx/ --add-module=fastdfs-nginx-module-master解压后的目录的绝对路径/src
      

      然后编译:

      sudo make
      

      这时候还会报一个错,错误原因是因为nginx编译的时候把警告当错误处理,事实上这个警告并不影响(程序员忽略警告):

      解决方法:

      找到objs目录下的Makefile

      vim Makefile

      删掉里面的-Werror(如果没有修改权限,修改一下这个文件的权限,chmod 777 Makefile)

      然后回到nginx-1.8.1目录中

      执行完成后继续执行sudo make

      执行sudo make install

  5. sudo cp fastdfs-nginx-module-master解压后的目录中src下mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf

  6. sudo vim /etc/fdfs/mod_fastdfs.conf

    修改内容:

    connect_timeout=10
    tracker_server=自己ubuntu虚拟机的ip地址:22122
    url_have_group_name=true
    store_path0=/home/itcast/fastdfs/storage
    
  7. sudo cp 解压缩的fastdfs-master目录中的conf中的http.conf /etc/fdfs/http.conf

  8. sudo cp 解压缩的fastdfs-master目录中conf的mime.types /etc/fdfs/mime.types

  9. 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;
                }
            }
    
    
  10. 启动nginx

  sudo  /usr/local/nginx/sbin/nginx

你可能感兴趣的:(FastDFS)