Introduction

Nextcloud is an open-source software suite for storing and sharing data, providing similar functionalities as cloud services like Google Drive, but with the advantage of personal control and privacy. This guide will cover the installation of Nextcloud on an Ubuntu server.

Prerequisites

  • A server running Ubuntu 20.04.
  • A non-root user with sudo privileges.
  • LAMP (Linux, Apache, MySQL, PHP) stack installed on your server.

Step 1: Install Apache and PHP

If you haven't already installed the LAMP stack, start by installing Apache and PHP, along with the required PHP modules:

sudo apt update sudo apt install apache2 libapache2-mod-php sudo apt install php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip

Step 2: Install and Configure MySQL

Install MySQL and secure your installation:

sudo apt install mysql-server sudo mysql_secure_installation

Log in to the MySQL shell:

sudo mysql

Create a database and user for Nextcloud:

CREATE DATABASE nextcloud; CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost'; FLUSH PRIVILEGES; EXIT;

Replace 'password' with a strong password.

Step 3: Download Nextcloud

Change to a web-accessible directory and download the latest version of Nextcloud:

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

Step 4: Configure Apache

Create an Apache virtual host file for Nextcloud:

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

Insert the following configuration:

``` DocumentRoot "/var/www/html/nextcloud" ServerName your-domain.com

Require all granted AllowOverride All Options FollowSymLinks MultiViews

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

ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined ```

Enable the new site and necessary Apache modules:

sudo a2ensite nextcloud sudo a2enmod rewrite headers env dir mime sudo systemctl restart apache2

Step 5: Access Nextcloud

Open your web browser and go to your domain (or IP address if you don't have a domain):

http://your-domain.com

Complete the setup by entering the database details you created earlier, and create an admin account.

Conclusion

Nextcloud is now installed and configured on your Ubuntu server. You can start uploading your files and managing them through your personal cloud.