目录

闪客云存储个人网盘通过docker php结合nginx网站部署

介绍

运营级可限速网盘系统网站源码是一款非常实用的系统,可以帮助您打造一个安全可靠的网盘分享平台!

提供三种存储方式:本地存储、阿里云存储和腾讯存储

网站部署

因为php服务是通过docker部署的,所以有的东西可能没有。

由于闪客云存储的代码中涉及到验证码,所以需要图片生成渲染支持,通过下面的方式把gd扩展安装上,

apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg-dev \
    libpng-dev \
    libwebp-dev \
    libxpm-dev \
    && docker-php-ext-configure gd \
        --with-freetype \
        --with-jpeg \
        --with-webp \
        --with-xpm \
    && docker-php-ext-install gd

安装过后验证:

php -m | grep gd

接下来就是nginx配置了

server {
    listen 80;
    server_name fkpan.com www.fkpan.com;
    rewrite ^(.*)$ https://www.fkpan.com$1 permanent;
}
server {
    listen       443 ssl;
    server_name fkpan.com www.fkpan.com;
    ssl_certificate      /usr/local/nginx/certs/www.fkpan.com.pem;
    ssl_certificate_key  /usr/local/nginx/certs/www.fkpan.com.key;


    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;


    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;




    client_max_body_size 1G;
    client_body_buffer_size 128k;


    gzip on;
    gzip_buffers 32 4K;
    gzip_comp_level 6;
    gzip_min_length 100;
    gzip_types application/javascript text/css text/xml application/font-woff;
    gzip_disable "MSIE [1-6]\.";




    if ( $host = 'fkpan.com') {
        rewrite ^/(.*)$ https://www.fkpan.com/$1 permanent;
        return 301;
    }
    location ^~ /.well-known/acme-challenge/ {
        default_type "text/plain";
        root  /usr/local/php/www;
    }
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|swf|woff2|woff|ttf|svg)$ {
        root /usr/local/php/www/fkpan/public;
        index index.html index.php;
    }


# URL重写规则
    location / {
        root /usr/local/php/www/fkpan/public;
        index index.html index.php;
        try_files $uri $uri/ /index.php?s=$uri&$args;
    }
    # 专门处理admin.php的路由
    location ~ ^/admin.php {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /www/fkpan/public/$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass 127.0.0.1:9300;
    }
    location ~ \.php$ {
#        fastcgi_cache WORDPRESS;
#        fastcgi_cache_valid 200 302 30d;
#        fastcgi_cache_valid 404 500 502 503 504 0s;
#        fastcgi_cache_valid any 30d;
#        fastcgi_cache_use_stale error timeout invalid_header http_500 http_503 updating;
#        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
#        add_header X-Cache "$upstream_cache_status - $upstream_response_time";
#        fastcgi_cache_key "$scheme$request_method$host$request_uri";
        include       fastcgi_params;
        fastcgi_pass  127.0.0.1:9300;
            fastcgi_index index.php;
         fastcgi_param  SCRIPT_FILENAME /www/fkpan/public/$fastcgi_script_name;
      }
      # 禁止访问敏感文件
      location ~ /\. {
          deny all;
      }
  }

nginx配置涉及下面知识点:

1 https证书申请配置

2 域名重定向www问题

3 静态文件通过nginx相应

4 对/admin.php开头的地址进行路由

5 对所有路径都重定向到index.php,这里记住除了参数还要把path带过去

6 client_max_body_size最大文件上传大小设置