How to Install NextCloud Server on Ubuntu

Nextcloud is free software created in 2016 that lets individuals set up their personal cloud storage. Similar to platforms like Dropbox, Google Drive, and OneDrive, Nextcloud offers comparable features. You can install the Nextcloud server software on Linux systems without any cost, and the client software works seamlessly on Windows, OS X, and Linux computers. Additionally, they provide mobile apps for both Android and iOS devices. Originating from the OwnCloud project, Nextcloud was developed by several members of the original OwnCloud team. While the two projects share many similarities, they differ in areas like interface design and licensing terms, especially for Enterprise versions.

Setting Up Your Own Nextcloud Server: A Step-by-Step Guide

Step 1: Access Root and Update Your System

  • Use the command sudo su to log in as the root user.
  • Update your system’s package list using the command apt-get update.

Step 2: Installing the LAMP Server and Necessary PHP Extensions

  • Install the LAMP (Linux, Apache, MySQL, PHP) server using the command apt-get install lamp-server^.
  • Install essential PHP extensions with the following command: apt-get install libapache2-mod-php7.1 php7.1-mbstring php7.1-curl php7.1-zip php7.1-gd php7.1-mysql php7.1-mcrypt.
  • Install the PHP XML extension: apt-get install php-xml.

Step 3: Downloading the Latest Nextcloud Server Release

  • Go to your web server’s root directory: cd /var/www/html.
  • Download the latest Nextcloud server (version 17.0.1 in this case) from their official website: wget https://download.nextcloud.com/server/releases/nextcloud-17.0.1.zip.

Step 4: Extracting the Files and Setting Permissions

  • Unzip the downloaded archive: unzip nextcloud-17.0.1.zip.
  • Rename the extracted folder for simplicity: mv nextcloud-17.0.1 nextcloud.
  • Remove the zip file: rm -rf nextcloud-17.0.1.zip.
  • Grant ownership of the Nextcloud directory to the web server user: chown -R www-data:www-data nextcloud/.

Step 5: Configuring MariaDB for Nextcloud

  • Run the MariaDB security script: mysql_secure_installation.
  • During the script setup, type “Y” for all prompts except for setting the root password.

Step 6: Creating a Dedicated Database

  • Log in to your MySQL server as the root user: sudo mysql -uroot -p (you’ll be prompted for your MySQL root password).
  • Select the MySQL database: use mysql;.
  • Create a database for Nextcloud: CREATE DATABASE nextcloud;.
  • Grant all necessary permissions on the Nextcloud database to a dedicated user: GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'nextcloud123';.
  • Apply the changes: FLUSH PRIVILEGES;.
  • Exit the MySQL shell: exit;.

Step 7: Disabling MariaDB Binary Logging

  • Open the MariaDB configuration file: nano /etc/mysql/my.cnf.
  • At the end of the file, add the following lines:
    • log-bin = /var/log/mysql/mariadb-bin
    • log-bin-index = /var/log/mysql/mariadb-bin.index
    • binlog_format = mixed

Step 8: Configuring the Apache Web Server

  • Enable the Apache rewrite module: sudo a2enmod rewrite.
  • Create a configuration file for Nextcloud: touch /etc/apache2/sites-available/nextcloud.conf.
  • Enable the newly created configuration: ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf.

Step 9: Setting Up the Virtual Host

  • Edit the Nextcloud configuration file: nano /etc/apache2/sites-available/nextcloud.conf.
  • Add the following configuration:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<VirtualHost *:80>
    ServerAdmin admin@ubuntu
    DocumentRoot "/var/www/html/nextcloud/"
    ServerName ipaddress 
    ServerAlias ubuntu 
    
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

    ErrorLog /var/log/apache2/your-domain.com-error_log
    CustomLog /var/log/apache2/your-domain.com-access_log common
</VirtualHost>
  • Restart the Apache web server to apply the changes: systemctl restart apache2.service.

You can now access your Nextcloud instance through a web browser using either of these addresses:

  • http://127.0.0.1/nextcloud
  • http://ipaddress/nextcloud (replace “ipaddress” with your server’s IP)

Reference: For more detailed instructions, refer to the official Nextcloud documentation: [https://docs.nextcloud.com/server/17/admin_manual/installation/index.html](https://docs.nextcloud.com/server/17/admin_manual/installation/index.html)

Licensed under CC BY-NC-SA 4.0
Last updated on Apr 20, 2024 21:02 +0100