Server Setup 10: Nextcloud Installation

If this is your first time looking at a post from this series, have a look at this summary: Server Setup 0: Contents

Database

Again, same as for WordPress, we need a database and a user. Same command to login as the root database server user:

sudo mysql -u root -p

a similar set of SQL commands to set up the nextcloud database:

CREATE USER 'nc_usr'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nc_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES on nc_db.* to 'nc_usr'@'localhost';
FLUSH privileges;
EXIT;

Disable Public Access – a different way

Like before, we don’t want the Nextclound site to be public until we’ve completed the installation & configuration. On the other hand, we don’t want to do the same as before (cutting our server off from the internet by turning off port forwarding on the router) because we have an active WordPress installation that people might be using.

To do this we’ll tell Apache to only respond to requests (for the Nextcloud site) from your internal network, not from the public internet:

sudoedit /etc/apache2/sites-available/nextcloud.conf

Add this section, just before the ErrorLog line, replacing the xxx.xxx.xxx with the first 3 blocks of your IP address on your network.

<Location />
    Require ip xxx.xxx.xxx.0/24
</Location>

Reload apache:

sudo systemctl reload apache

Download the installer script

Navigate to the nextcloud folder

cd /var/www/nextcloud

Download the installer script, and pass ownership of it and the entire nextcloud folder to www-data (which is apache, remember).

sudo wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
sudo chown -R www-data:www-data /var/www/nextcloud

We should also create a data folder outside the /var/www folder, which improves security:

sudo mkdir /var/nc_data
sudo chown -R www-data:www-data /var/nc_data

Run Installation Script

On the client machine, open a browser and go to nextcloud.example.org/setup-nextcloud.php

You should see the Setup Wizard, most it should be easy to understand, click your way through:

Put a “.” in the box like it says because the Nextcloud installer is already in the correct place

  • Enter the details for the database and database user you created above.
  • Make an admin account with a strong password.
  • Change the data folder to the one we just created: /var/nc_data,
  • I’d recommend unticking the Install recommended apps box. You can add them later if you like.

Once this is done you should be able to log in and start using it!

Leave a Reply

Your email address will not be published.