NextCloud is an open source and free cloud storage network disk project. Anyone can freely obtain the NextCloud program and build a private and free network disk at home or company. It's a private, secure, and full-featured file sync and share solution that's fully controlled by you, the user, and it was an instant hit.

I have also shared a lot of NextCloud installation and deployment tutorials before. The most interesting one is NextCloud paired with Aria2 to achieve offline downloading. Because NextCloud comes with music and video playback functions and supports WebDAV, etc., it is completely possible to create a cloud storage platform or cloud disk based on NextCloud.

NextCloud has a function of mounting external storage, which allows you to mount third-party storage, local hard disks, etc. as storage hard disks on the server as NextCloud's storage service. However, many people will have permission problems during the operation, such as being unable to read files or delete files.

This article will share how to manually install and deploy NextCloud on Oneinstack and add external storage. At the same time, we will also share a NextCloud offline download plug-in, ocDownloader, which can be combined with Aria2 to realize offline downloading of Http, FTP and BT seeds, and at the same time, you can use NextCloud to manage downloads. file, which perfectly solves the problem of file permissions.

Oneinstack manually installs NextCloud and uses Aria2 offline download and ocDownloader plug-in configuration

For more offline downloading methods and tools, you can try these:

  1. Windows and Linux installation use Aria2 to download resources offline and manage files online to play videos
  2. Nextcloud offline download construction method-integrate Aria2, AriaNg, and Aria2 WebUI to achieve offline downloading
  3. Raspberry Pi Installation NextCloud Tutorial-Self-built home private cloud LAN sharing

PS: Updated on March 31, 2018, If you want to build an audio and video network disk center that can be shared and played online, you can try: Plex perfect personal video cloud disk building tutorial-Plex Media Server installation and usage instructions .

1. Install NextCloud on Oneinstack

NextCloud official website:

  1. Official website: https://nextcloud.com/
  2. Plug-in: https://apps.nextcloud.com/apps/ocdownloader
  3. Project: https://github.com/e-alfred/ocdownloader

OneinStack installation is quite simple. Since we want to run NextCloud on Oneinstack, please select LAMP mode during the installation process. It is also recommended to install all related components. Refer to the previous article: One-click installation script of OneinStack - easily deploy Let’s Encrypt certificate to configure HTTPS site.

1.1  NextCloud installation

Open the browser and enter the NextCloud installation interface. If you get the following error message:

PHP is set up to remove inline blocks, which will cause multiple core applications to be inaccessible.
This may be caused by caches/accelerators, such as Zend OPcache or eAccelerator.

As shown below:

Solution: Modify the Opcache parameters in php.ini. If it is Oneinstack, it needs to be in /usr/local/php/etc/php.d/ext- Modified in opcache.ini . Find this code and change it to: opcache.save_comments=1 , because the default is 0, just restart php-fpm after changing it.

1.2  NextCloud configuration

After installing NextCloud, entering the settings will generally prompt several security questions:

For "PHP module 'fileinfo' is missing. We strongly recommend enabling this module to obtain the most accurate results during MIME type detection." You can execute: ./addons.sh to install the fileinfo module.

For "HTTP request header "Strict-Transport-Security" is not configured for at least "15552000" seconds. For enhanced security considerations, we recommend enabling HSTS as described in the security tips." Go to /usr/local/apache/ conf/vhost, modify xxx.conf.

Just add the following code.

Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"

For "Memory cache is not configured. If available, please configure memcache to enhance performance..", enter the config folder to modify the configuration file and add the following code.

'memcache.local' => 'OCMemcacheRedis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),

After setting up according to the above method, NextCloud basically has no prompts. We can see that Oneinstack basically has no problem running NextCloud.

2. NextCloud install ocDownloader

Go to the NextCloud plug-in installation page and search for ocDownloader to install it directly online.

After installation and activation, you can enter the ocDownloader panel from the top toolbar, where we can see adding downloads and viewing download tasks.

3. Install Aria2 on NextCloud server

The NextCloud plug-in ocDownloader is installed above, but it cannot be used yet. We need to install Aria2 on the server. The code is as follows:

wget https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo -O /etc/yum.repos.d/rhscl-devtoolset-3-epel-6.repo
yum install devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-binutils devtoolset-3-gcc-gfortran
scl enable devtoolset-3 bash
gcc --version
wget https://github.com/aria2/aria2/releases/download/release-1.32.0/aria2-1.32.0.tar.gz
tar xzvf aria2-1.32.0.tar.gz
cd aria2-1.32.0
./configure
make
make install

If your gcc compiler version number is high enough, you can skip the first three steps and just download aria2 with wget and compile it. Edit sudoers file:

vi /etc/sudoers

Find this part of the code in the image below:

Will:

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

change into:

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

Exit vi and save. Because sudoers is a read-only file, a warning may pop up when exiting vi. To force exit, use the following command:

:wq!

Now you can use sudo to run aria2 as the www user:

sudo -u www aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all -c --dir /root/downloads -D

By default, the file download and save path we choose for this command line startup is /root/downloads, but in fact this path is not effective. Its purpose is only to enable aria2 to start successfully. We can set the file saving path in the ocDownloader plug-in later.

4. NextCloud uses ocDownloader plug-in

Enter NextCloud's ocDownloader operation interface, click Add Download Task, and you can start offline downloading. The following is a demonstration built by wzfou.com:.

ocDownloader supports BT and magnet link downloads.

ocDownloader will create a download directory in NextCloud. All downloaded files will be placed in this directory. Downloaded files can be viewed from NextCloud.

After testing by wzfou.com, NextCloud can normally view and delete files downloaded by ocDownloader, and there are no problems with permissions.

5. Summary

One problem with Nginx when running NextCloud is the problem of static rules. Oneinstack recommends using Apache when running NextCloud. The official NextCloud tutorials all use Apache, which has the best compatibility.

In general, it is quite convenient for NextCloud to use ocDownloader to call Aria2 for offline download. It solves the problem of file read and write permissions in the Nextcloud offline download setup method, and can normally read, write and delete files downloaded by Aria2.

Leave a Reply