自建私有雲Owncloud+Nginx(支持16G大文件上傳)


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 restart

$ sudo service nginx restart

配置

瀏覽器打開http://127.0.0.1:10010,MariaDB是Mysql的開源分支(mysql被oracle收購了),適合大規模使用,對並發和性能要求比較高的場景。SQLite3適合小規模使用。此處使用SQLite3。詳見 https://doc.owncloud.org/server/latest/admin_manual/configuration_database/db_conversion.html 和https://doc.owncloud.org/server/latest/admin_manual/configuration_database/linux_database_configuration.html

owncloud.png

配置域名

詳見 https://doc.owncloud.org/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html

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,用管理員用戶名密碼登陸

下載客戶端

參見 https://owncloud.org/install/#install-clients

 

from https://anjia0532.github.io/2017/04/05/owncloud/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM