Blog
October 1, 2019

Setting Up Your Own NextCloud Personal Cloud On Your LAN

Setup Commands in Ubuntu 18.04 LTS Desktop or Server (Post-Install)

Adding a user

sudo adduser jdoe

Adding a user to the sudo group

sudo usermod -aG sudo jdoe

Update packages

sudo apt update

sudo apt dist-upgrade

Set the hostname

sudo nano /etc/hostname

sudo nano /etc/hosts

Reboot to save all changes so far

sudo reboot


==== Download Nextcloud Go to: https://nextcloud.com/install/

Click "Download for server" and copy the link address


==== Set up database server

sudo apt install mariadb-server

sudo mysql_secure_installation

Create Nextcloud Database

sudo mariadb

CREATE DATABASE nextcloud;

SHOW DATABASES;

GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'mypassword';

FLUSH PRIVILEGES;

CTRL+D to exit

Install required packages

sudo apt install php php-cli php-common php-curl php-xml php-gd php-mbstring php-zip php-mysql

Make sure apache2 is listed as a package in the list to be installed; if not, this must be installed separately

Check status with systemctl

systemctl status apache2

systemctl status mariadb

Install zip and unzip nextcloud

sudo apt install unzip

unzip nextcloud-<version#>.zip

Organize Apache files

mv nextcloud nc.lanlocal.asuscomm.com

sudo chown -R www-data:www-data nc.lanlocal.asuscomm.com

sudo mv nc.lanlocal.asuscomm.com /var/www

ls -l /etc/apache2/sites-enabled/

sudo a2dissite 000-default.conf

sudo systemctl reload apache2

Add Apache virtual host for Nextcloud

sudo nano /etc/apache2/sites-available/nc.lanlocal.asuscomm.com.conf

<VirtualHost *:80>

  DocumentRoot "/var/www/nc.lanlocal.asuscomm.com"

  ServerName nc.lanlocal.asuscomm.com

 

<Directory "/var/www/nc.lanlocal.asuscomm.com/">

  Options MultiViews FollowSymlinks

  AllowOverride All

  Order allow,deny

  Allow from all

</Directory>

 

TransferLog /var/log/apache2/nc.lanlocal.asuscomm.com_access.log

ErrorLog /var/log/apache2/nc.lanlocal.asuscomm.com_error.log

 

</VirtualHost>

Enable the site

sudo a2ensite nc.lanlocal.asuscomm.com.conf

Configure PHP

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

memory_limit = 512M

upload_max_filesize = 200M

max_execution_time = 360

post_max_size = 200M

date.timezone = America/New York

Enable required Apache mods

sudo a2enmod rewrite

sudo a2enmod headers

sudo a2enmod env

sudo a2enmod dir

sudo a2enmod mime

sudo a2enmod ssl

sudo systemctl restart apache2

Create an SSL certificate (Using letsencrypt)

This step should be undertaken only if you are going to access your Personal Cloud outside of your network and you have the ability to create an A-Record for your site via your ISP's DNS Server or local DNS Server.

sudo add-apt-repository ppa:certbot/certbot

Verify by running ls -l /etc/apt/sources.list.d

sudo apt install python-certbot-apache

sudo certbot --apache -d nc.lanlocal.asuscomm.com