Build your own cloud disk service

preface

Recently, I sorted out some video documents in the hard disk. Although I had classified them before, it was still a bit messy after a long time. I had to rummage for a long time to find something. So I thought I could do a gadget, meaning, build their own cloud disk service.

Hard and soft listing

  • One external hard disk (for mounting)
  • Broadband, router (at home)
  • SSH Connection tool (SecureCRT, Xshell)
  • Nginx, PHP, OwnCloud, ngrok
  • Raspberry PI 3B+ 1 with system installed (charger, CPU cooling fan, etc.)

Configure the environment

Install Nginx

sudo apt-get update
sudo apt-get install nginx
sudo service nginx start
Copy the code

Installing PHP

# OwnCloud requires a base library that must be installedSudo 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 restartCopy the code

MySql installation

sudo apt-get install mysql-server
sudo apt-get install mysql-client
Copy the code

After the installation is complete, enter the database without entering the password:

sudo mysql -u root -p
Copy the code

Change password:

sudo systemctl restart mysql
sudo systemctl status mysql
Copy the code

Cloud disk installation

Download the latest resources, foreign websites, may be slightly slow, please wait patiently:

Wget HTTP: / / https://download.owncloud.org/community/owncloud-10.1.1.tar.bz2Copy the code

Download complete, unzip the file:

Sudo tar - xvfowncloud - 10.1.1. Tar..bz2Copy the code

Cloud disk OwnCloud configuration file:

8081 listen 8081 default_server; Listen [: :] : 8081 default_server; # install directory root /home/pi/owncloud; The index index. Phpindex. HTM; client_max_body_size 10G; fastcgi_buffers 64 4K; gzip off; rewrite ^/caldav(.*)$ /remote.php/caldavThe $1 redirect; 
 rewrite ^/carddav(.*)$ /remote.php/carddavThe $1 redirect;
 rewrite ^/webdav(.*)$ /remote.php/webdavThe $1redirect; 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/[^\/]+/)$The $1/index.html; 
 try_files $uri $uri/ /index.php; } location ~ \.php(? : ${| /) fastcgi_pass Unix: / run/PHP/php7.0 - FPM. The 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; }}Copy the code

After the configuration is complete, enter the installation interface, enter the administrator account password and database information, and click Next to successfully install:

Initial page:

Intranet through

If you want access on a non-LAN, you need to add a penetrator to access our Intranet services.

First, we need to upload the previously generated ngrok client (Linux_ARM) to raspberry PI:

Then, create an ngrok.yml configuration file:

server_addr: "ngrok.52itstyle.vip:4443"
trust_host_root_certs: false
tunnels:
 owncloud:
 proto:
 http: "8081"
Copy the code

Start the service:

./ngrok -config=ngrok.yml start owncloud
Copy the code

SSH is turned off, so make ngrok run in the background:

Install Screen first
sudo apt-get install screen
Copy the code

Run after:

Screen-s Any name (e.g., keepngork)Copy the code

Then run the ngrok startup command:

./ngrok -config=ngrok.yml start owncloud
Copy the code

Finally press the shortcut key:

 ctrl+A+D
Copy the code

If the following occurs, ngrok can be kept running in the background.

[detached from 14930.keepngork]
Copy the code

Finally, configure the trusted domain name, otherwise the domain cannot be accessed through:

sudo vim config/config.php
Copy the code

Add proxy domain name:

array (
 0 => '192.168.1.157:8081', 1 = >'owncloud.ngrok.52itstyle.vip',),Copy the code

Front desk:

Background:

Audio playback:

summary

Cloud disk in the Intranet experience is quite good, search, collection, sharing, very complete function. But with proxy penetration, uploading large files is a bit slow. Of course, if you want serious use, it is best to mount a T-level hard disk.

More Python tutorials will continue to be updated!