?
最近在整理硬盘中的一些视频文档,虽然之前进行了分类,但时间一长,还是有点乱,找个东西得翻找半天。于是乎,就有了下面这个小玩意,自建云盘服务。
sudo apt-get update
sudo apt-get install nginx
sudo service nginx start
# owncloud 需要的基础库,必须要安装
sudo apt-get install php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-mcrypt php7.0-cgi
sudo apt-get install php7.0-intl php7.0-mysql php7.0-zip php7.0-dom php7.0-mbstring
sudo service php7.0-fpm restart
sudo apt-get install mysql-server
sudo apt-get install mysql-client
安装完成以后进入数据库,无需输入密码:
sudo mysql -u root -p
修改密码:
sudo systemctl restart mysql
sudo systemctl status mysql
下载最新资源,国外网站,可能略慢,请耐心等待:
wget https://download.owncloud.org/community/owncloud-10.1.1.tar.bz2
下载完成,解压文件:
sudo tar -xvf owncloud-10.1.1.tar.bz2
云盘 owncloud 配置文件:
server {
# 80端口被占用,这里使用8081
listen 8081 default_server;
listen [::]:8081 default_server;
# 安装目录
root /home/pi/owncloud;
index index.php index.htm;
client_max_body_size 10G;
fastcgi_buffers 64 4K;
gzip off;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
deny all;
}
location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ /index.php;
}
location ~ \.php(?:$|/) {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
#ifastcgi_pass php-handler;
}
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}
}
配置完成后,进入安装界面,输入管理员账号密码以及数据库相关信息,点击进入下一步即可安装成功:
初始页面:
如果你想要在非局域网中访问,就需要加一个穿透,来访问我们内网的服务。
首先,我们要把之前生成的 ngrok 客户端(linux_arm)上传到树莓派:
然后,创建一个 ngrok.yml 配置文件:
server_addr: "ngrok.52itstyle.vip:4443"
trust_host_root_certs: false
tunnels:
owncloud:
proto:
http: "8081"
启动服务:
./ngrok -config=ngrok.yml start owncloud
SSH是要关闭的,所以要使 ngrok 后台运行:
# 首先安装screen
sudo apt-get install screen
之后运行:
screen -S 任意名字(例如:keepngork)
然后运行ngrok启动命令:
./ngrok -config=ngrok.yml start owncloud
最后按快捷键:
ctrl+A+D
如果出现以下,既可以保持ngrok后台运行。
[detached from 14930.keepngork]
最后,配置信任域名,否则穿透域名无法访问:
sudo vim config/config.php
加入代理域名:
array (
0 => '192.168.1.157:8081',
1 => 'owncloud.ngrok.52itstyle.vip',
),
演示地址:http://owncloud.ngrok.52itstyle.vip
前台:
后台:
音频播放:
云盘在内网体验还是蛮好的,搜索、收藏、分享,功能很齐全。只是加了代理穿透以后,上传大文件有点慢。当然了如果想正儿八经的使用,最好挂载一个 T 级别的硬盘。
?
?