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/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
sudo systemctl restart mysqld
sudo systemctl restart apache2
sudo systemctl restart php7.0-fpm.service

Prepate MariaDB server for 4-byte characters prior to creating database:

sudo nano mariadb.conf.d/50-server.cnf

Once inside that file, copy these configurations under the [mysqld] block and restart the service:

innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=1

It is now time to set up your database:

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 nextclouduser@localhost IDENTIFIED BY 'put-password-here';
> GRANT ALL PRIVILEGES ON nextcloud.* to nextclouduser@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 by finding the line `memory_limit = ` and changing it to 1G:

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

– – – – –

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 15:27

computing/nextcloud.1560636796.txt.gz · Last modified: 2019/06/15 22:13 by oemb1905