Nextcloud Install Notes

Nextcloud is a utility that allows you to manage your files just like Google Docs. I have Nextcloud running on my home network and this article includes the steps needed to get this done.

I chose to install Nextcloud in a different directory other that /var/www/html. Instead, I chose to install Nextcloud in a different directory where there was more storage space.

First lets update our system

sudo apt update -y

Install Apache

sudo apt install apache2 libapache2-mod-php

Install PHP along with a few PHP modules

sudo apt-get install -y php php-gd php-curl php-zip php-dom php-xml php-simplexml php-mbstring

Install MySQL

apt install mysql-server php-mysql

Configure MySQL

sudo mysql_secure_installation

Choose default for all settings

mysql -u root -p

Create the Database, grant access to a user, and flush privileges with the commands below.

CREATE DATABASE nextcloud;
GRANT ALL ON nextcloud.* TO 'username'@'localhost' IDENTIFIED BY 'yourPassword';
FLUSH PRIVILEGES;
EXIT;

Decide where you want to install Nextcloud. By default, it would normally go in /var/www/html/nextcloud. For this article I will choose default. We will also choose to get the package from Nextcloud that includes all of the PHP modules

mkdir /var/www/html/nextcloud
cd /var/www/html/nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-22.0.0.zip
unzip nextcloud--22.0.0.zip
sudo chown -R www-data:www-data /var/www/html/nextcloud

Now create the Apache configuration file for Nextcloud

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

Copy and paste the below code into the nextcloud.conf file

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nextcloud
Alias /nextcloud "/var/www/html/nextcloud/"
 
<Directory "/var/www/html/nextcloud/">
Options +FollowSymlinks
AllowOverride All
 
<IfModule mod_dav.c>
Dav off
</IfModule>
 
Require all granted
 
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</Directory>
 
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error_log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access_log common
</VirtualHost>

Enable the site with the Apache command a2ensite

sudo a2ensite nextcloud.conf

Restart Apache and check status

sudo systemctl restart apache2
do systemctl status apache2

Go to the server IP to complete the installation of Nextcloud.