Friday 21 September 2018

Nextcloud on Crostini running in its own container



Nextcloud (a fork of Owncloud) provides file hosting on a private server and when running on Crostini provides a simple way of accessing Chrome OS files from different local devices.

It is simple to set up (example) and an advantage of Crostini in allowing multiple containers means you can run Nextcloud effectively in background while you explore and modify your default 'penguin' container.

Start by creating a new container based on the original penguin one. I already made a copy of 'penguin' and called it 'google' but you can take your existing container and add Nextcloud if you prefer.


In your VM or 'termina' enter:

  lxc copy google nextcloud # or lxc copy penguin nextcloud
  lxc start nextcloud
  lxc exec nextcloud -- bash

Then make sure everything is updated by entering:

  sudo apt update
  sudo apt upgrade

Nextcloud depends on an underlying LAMP server so first install Apache:

  sudo apt install apache2


Create the configuration file:

  sudo vi /etc/apache2/sites-available/nextcloud.conf


and add the following text:

Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud

</Directory>

Next create a symolic link to the file:

  sudo ln -s /etc/apache2/sites-available/nextcloud.conf 
    /etc/apache2/sites-enabled/nextcloud.conf

and enable the following modules by entering:

  sudo a2enmod rewrite
  sudo a2enmod headers

Finally restart Apache:

  sudo systemctl restart apache2



Secondly install MariaDB:

  sudo apt install mariadb-server


Create a database administrator account first by entering:

  sudo mariadb

and then:

  create user dba@localhost identified by 'password';
  grant all privileges on *.* to dba@localhost with grant option;
  flush privileges;
  exit


Thirdly install PHP:

  sudo apt install libapache2-mod-php7.0 php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring php7.0-intl php-imagick php7.0-xml php7.0-zip php7.0-mcrypt # on Debian stretch

or (if your container is Ubuntu 18.04):

  sudo apt install libapache2-mod-php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php-imagick php7.2-xml php7.2-zip # on Ubuntu 18.04



Finally install Nextcloud:

  cd /var/www
  sudo apt install wget # only on Debian stretch
  sudo wget https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip
  sudo unzip nextcloud-14.0.0.zip
  sudo rm nextcloud-14.0.0.zip
  sudo chown -R www-data:www-data nextcloud


Make a note of the container's IP address:

hostname -I

and configure a port forwarding rule using the 'Connection Forwarder' app:
 
  0.0.0.0:8123 -> 100.115.92.206:80


Now open a Chrome window with:

  http://localhost:8123/nextcloud



and enter your details:


and Nextcloud will start:



Finally to be able to access your Nextcloud container from other devices on your LAN enter:

sudo vi /var/www/nextcloud/config/config.php

and change 'trusted_domains' by removing the port number and adding a line for your Chrome device's IP address:

'trusted_domains' =>
  array (
   0 => 'localhost',
   1 => '10.88.88.123',
),



You also need to prevent your Chrome device from sleeping so under Chrome's 'Settings' then 'Power' select 'Keep display on'.

Now you can add files from Chrome OS:


and access them over the LAN from another device:



Please donate if you find this guide useful using the following link http://goo.gl/nXWSGf.

No comments:

Post a Comment