私有云盤Owncloud_v9.1+Nginx_v1.1(支援16G大檔案上傳)

趙安家發表於2019-02-27

Owncloud官網

桌面版支援Windows,Mac,Linux 移動版本支援,android,ios,blackberry

環境

  • Ubuntu-16.04_64
  • Owncloud9.14-2.1
  • SQLite3
  • PHP7
  • Nginx 1.10.0

最簡單安裝

根據linux版本選擇相應版本

owncloud-9.1

安裝

以Ubuntu-16.04 安裝owncloud-9.14-2.1為例

用root許可權新增owncloud金鑰

su root

wget -nv https://download.owncloud.org/download/repositories/9.1/Ubuntu_16.04/Release.key -O Release.key
apt-key add - < Release.key複製程式碼

用root許可權新增owncloud軟體源

sh -c "echo `deb http://download.owncloud.org/download/repositories/9.1/Ubuntu_16.04/ /` > /etc/apt/sources.list.d/owncloud.list"
apt  update -y && apt install owncloud -y複製程式碼

原始碼安裝

安裝PHP7

sudo apt-get install -y php7.0-common  php7.0-gd php7.0-json php7.0-mysql php7.0-curl  php7.0-intl php7.0-mcrypt php-imagick  php7.0-zip php7.0-xml php7.0-mbstring複製程式碼

安裝資料庫

#mariadb
sudo apt-get install -y mariadb-server php7.0-mysql

#sqlite3
sudo apt-get install -y sqlite3 php7.0-sqlite3複製程式碼

安裝web容器

#apache2
sudo apt-get install -y apache2 libapache2-mod-php7.0

#nginx
sudo apt-get install -y nginx php7.0-fpm複製程式碼

修改fpm配置檔案(nginx)

$ vi /etc/php/7.0/fpm/pool.d/www.conf複製程式碼

修改listen = /run/php/php7.0-fpm.socklisten=127.0.0.1:9000(大約36行)

放開env的註釋(大約384-388行)

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp複製程式碼

下載最新原始碼

$ wget -P /tmp https://download.owncloud.org/download/community/owncloud-latest.zip  && sudo unzip /tmp/owncloud-latest.zip -d /var/www/ && rm -rf /tmp/owncloud-latest.zip複製程式碼

給www-data授權

sudo chown -R www-data:www-data /var/www/owncloud/複製程式碼

參考資料

官方nginx+https配置

支援大檔案上傳(16G)

我的nginx配置

nginx

$ vi  /etc/nginx/sites-enabled/owncloud.conf

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

server {
    listen 10010;
    server_name 127.0.0.1;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this topic first.
    #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

    # Path to the root of your installation
    root /var/www/owncloud/;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you`re planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

    location = /.well-known/carddav {
        return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
        return 301 $scheme://$host/remote.php/dav;
    }

    location /.well-known/acme-challenge { }

    # set max upload size
    client_max_body_size 16400M;
    fastcgi_buffers 64 4K;
    fastcgi_read_timeout 600;
    client_body_buffer_size 1048576k;
    client_body_temp_path /tmp/owncloud;

    # Disable gzip to avoid the removal of the ETag header
    gzip off;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;

    location / {
        rewrite ^ /index.php$uri;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        return 404;
    }
    location ~ ^/(?:.|autotest|occ|issue|indie|db_|console) {
        return 404;
    }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34]).php(?:$|/) {
        fastcgi_split_path_info ^(.+.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        #fastcgi_param HTTPS on;
        fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off; #Available since nginx 1.7.11
    }

    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri $uri/ =404;
        index index.php;
    }

    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~* .(?:css|js)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into this topic first.
        #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don`t log access to assets
        access_log off;
    }

    location ~* .(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don`t log access to other assets
        access_log off;
    }
}複製程式碼

php.ini


$ sudo vi /etc/php/7.0/fpm/php.ini

##修改以下幾個配置引數

; should be bit bigger than upload_max_filesize 16400M = 16G + 16M = 16 * 1025 MB
post_max_size = 16400M

; cannot be bigger than post_max_size
upload_max_filesize = 16G

; on online servers this could require bigger values (my server is at home)
max_input_time = 3600

; from ownCloud documentation - not sure if is required
output_buffering = Off

; not sure if it is required [3] but it seems like ownCloud needs time to move the file to it`s
; final place after upload and that can take quite some time for big files
max_execution_time = 1800

; you may also want to point this to a folder having enough space for big files being uploaded
upload_tmp_dir = /tmp/owncloud複製程式碼

啟動服務

$ sudo service php7.0-fpm start

$ sudo service nginx stop複製程式碼

配置

瀏覽器開啟http://127.0.0.1:10010,MariaDB是Mysql的開源分支(mysql被oracle收購了),適合大規模使用,對併發和效能要求比較高的場景。SQLite3適合小規模使用。此處使用SQLite3。詳見 doc.owncloud.org/server/late…doc.owncloud.org/server/late…

私有云盤Owncloud_v9.1+Nginx_v1.1(支援16G大檔案上傳)
owncloud.png

配置域名

詳見 doc.owncloud.org/server/late…

sudo vi /var/www/owncloud/config/config.php複製程式碼

修改

`trusted_domains` => 
  array (
    0 => `127.0.0.1:10010`,
    1 => `域名`,
  ),複製程式碼

修改

`overwrite.cli.url` => `http://域名`,複製程式碼

建立使用者

瀏覽器訪問http://127.0.0.1:10010/settings/users,用管理員使用者名稱密碼登陸

下載客戶端

參見 owncloud.org/install/#in…

本人原創,轉載請宣告

github pages
簡書
掘金

相關文章