User Tools

Site Tools


computing:nextcloud

This is an old revision of the document!



  • Nextcloud
  • Jonathan Haack
  • Haack's Networking
  • netcmnd@jonathanhaack.com

Nextcloud


This tutorial is for users of Debian GNU/Linux seeking to set up a basic self-hosted or VPS Nextcloud instance. Before you start, you should read The issue with Public Cloud, which covers a little more about the value of hosting your own content/cloud instance. Also, do not proceed with this tutorial until you have a LAMP stack set up and until you have properly configured TLS encryption for your site. If you need help with doing that, please see the Apache Survivial tutorial. Now that your webserver is set up and securely accessed, proceed:

cd /var/www/test.com/public_html/
sudo wget https://download.nextcloud.com/server/releases/nextcloud-16.0.1.zip  
sudo unzip nextcloud-16.0.1.zip
sudo mv /var/www/test.com/public_html/nextcloud/* /var/www/test.com/public_html/
sudo mv /var/www/test.com/public_html/.htaccess /var/www/test.com/public_html/.htaccess
sudo rm -r nextcloud  

Make sure to see if there is a newer version than what I have in the example above. The latest version of Nextcloud server can be found here Next Cloud Download. Okay, now it is time to set up permissions. Basically, Nextcloud relies on a set up similar to Moodle or DokuWiki, where the primary web root is owned by www-user and is also part of that group. For security, place the Nextcloud data directory outside of the web server's root directory. Here goes:

cd /var/www/test.com/public_html/
sudo chown www-data:www-data -R /var/www/test.com/public_html/* 
sudo mkdir /var/www/test.com/nextclouddata
sudo chown www-data:www-data -R /var/www/test.com/nextclouddata

Now it is time to set up the database so that when we leverage the web app to finish setup, it actually has a dedicated database to connect to. Again, since this tutorial assumes you have a basic LAMP stack already set-up, it skips right to set up in MySQL:

sudo mysql -u root -p

Enter your password for sudo and then for MySQL. Once inside MySQL command mode, you will have a “>” prompt. You will need to create a separate database for Nextcloud, a dedidcated database user for Nextcloud, and establish proper permissions for the dedicated database user. Here goes:

> CREATE DATABASE nextcloud;
> CREATE USER nextcloud@localhost IDENTIFIED BY 'put-password-here';
> GRANT ALL PRIVILEGES ON nextcloud.* to nextcloud@localhost IDENTIFIED BY 'put-password-here';
> FLUSH PRIVILEGES;
> EXIT;

Okay, you can now proceed to the website test.com and make finish the remaining set up using the Nextcloud website that is now active. Let's first restart the web server and mysql services:

sudo systemctl restart mysql
sudo systemctl restart apache2

Ok, now that those services are restarted, you should be able to access your website. Visit test.com in your browser, or if you are not using a domain, then visit localhost in your web browser of choice. When you do that you are given the following choices that match the configuration options above:

  • create new user name: <yourchoice, but do not use root, admin, etc., since this is public facing>
  • create new user pass: <this is public facing and is the admin user, so make it a bit beefy>
  • specify data folder: /var/www/test.com/nextclouddata
  • database user name: nextcloud
  • database name: nextcloud
  • database location: localhost

Once you are done, you can now use Nextcloud at will. Make sure you have a good backup in place, however, before you put significant time into migrating your files, calendars, contacts, and other workflow into it. With regard to backups, visit my RAID tutorial, or my rsync and rsnapshot tutorial. Happy clouding.

Nextcloud offered this:

sudo find /var/www/codetalkers.group/public_html/ -type f -print0 | xargs -0 chmod 0640
sudo find /var/www/codetalkers.group/public_html/ -type d -print0 | xargs -0 chmod 0750

But that gives me errors, so I developed this (also two lines), from within ServerRoot…

cd /var/www/codetalkers.group/public_html/
sudo chmod 0640 *.php *.txt *.html AUTHORS COPYING
sudo chmod 0750 {3rdparty,apps,assets,config,core,data,lib,ocm-provider,ocs,ocs-provider,resources,settings,themes,updater} 
sudo chown -R root:www-data /var/www/codetalkers.group/public_html
sudo chown www-data:www-data {apps,assets,config,data,themes,updater}  
sudo chmod 0755 /var/www/codetalkers.group/public_html/occ
sudo chmod 0644 /var/www/codetalkers.group/public_html/.htaccess
sudo chown root:www-data /var/www/codetalkers.group/public_html/.htaccess

And finally you have an instance … Haack's Cloud.

Update: I was having trouble getting Nextcloud to recognize my opcache settings when I used the default php.ini, so I located the php.ini specifically for opcache in the daemon directory provided on Debian and put the changes there, and then it worked:

nano /etc/php/7.0/cli/conf.d/10-opcache.ini

The settings below are currently recommended by Nextcloud, but always check/verify this before copying and pasting:

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

Adjust the memory limit for php:

sudo nano /etc/php/7.2/apache2/php.ini

Find the `memory_limit = ` line and change the value to 1G. OK, now you can close the file, restart services:

sudo systemctl restart mysql-server
sudo systemctl restart apache2
sudo systemctl restart php7.0-fpm.service

Refresh Nextcloud and it will recognize the optimizations. Or, if you are new and need to copy and paste, try this and be careful:

`cd /var/www/html sudo wget https://download.nextcloud.com/server/releases/nextcloud-15.0.8.zip sudo unzip nextcloud-15.0.8.zip sudo mv /var/www/html/nextcloud/* /var/www/html/ sudo mv /var/www/html/nextcloud/.htaccess /var/www/html/.htaccess sudo mv /var/www/html/nextcloud/.user.ini /var/www/html/.user.ini sudo rm -r nextcloud sudo chown www-data:www-data -R /var/www/html/* sudo mkdir /var/www/nextclouddata sudo chown www-data:www-data -R /var/www/nextclouddata sudo mkdir assets sudo mkdir data sudo chmod 0640 *.php *.txt *.html AUTHORS COPYING sudo chmod 0750 {3rdparty,apps,assets,config,core,data,lib,ocm-provider,ocs,ocs-provider,resources,settings,themes,updater} sudo chown -R root:www-data /var/www/html sudo chown www-data:www-data {apps,assets,config,data,themes,updater} sudo chmod 0755 /var/www/html/occ sudo chmod 0644 /var/www/html/.htaccess sudo chown root:www-data /var/www/html/.htaccess sudo systemctl restart mysql-server sudo systemctl restart apache2 sudo systemctl restart php7.0-fpm.service`

– – – – –

This tutorial is a designated “Invariant Section” of the “Technotronic” section of Haack's Wiki as described on the Start Page.

oemb1905 2019/06/15 14:09

computing/nextcloud.1560633919.txt.gz · Last modified: 2019/06/15 21:25 by oemb1905