Come hang with us on Discord and chat directly with the team!Discordtop-bar-close-icon

2024-10-10

How to Install Nextcloud on Ubuntu Latest

tutorials
img

Introduction

Nextcloud is a robust open-source platform for file sharing and collaboration, offering a self-hosted alternative to proprietary cloud services. This guide will walk you through the installation process of Nextcloud on the latest version of Ubuntu.

Prerequisites

Before starting, ensure your server meets the following requirements:

  • A server running the latest version of Ubuntu.
  • A LAMP (Linux, Apache, MySQL, PHP) stack installed on your server.
  • Access to a terminal with root privileges.

Step 1: Update Your System

Begin by updating your package list and upgrading all system packages to their latest versions. Open your terminal and execute these commands:

sudo apt update
sudo apt upgrade -y

Step 2: Install Apache and PHP

Nextcloud requires a web server and PHP. Install Apache and the required PHP modules:

sudo apt install apache2
sudo apt install php libapache2-mod-php php-mysql php-xml php-mbstring php-curl php-gd php-zip php-intl php-bcmath php-gmp

Step 3: Install MySQL

Install MySQL server and secure the installation:

sudo apt install mysql-server
sudo mysql_secure_installation

Follow the prompts to secure your MySQL installation.

Step 4: Download and Configure Nextcloud

Download the latest version of Nextcloud from the official website or use wget to download directly:

cd /var/www/html
wget https://download.nextcloud.com/server/releases/nextcloud-x.y.z.zip

Replace x.y.z with the latest version number. Extract the downloaded file:

sudo apt install unzip
unzip nextcloud-x.y.z.zip

Move the extracted files to the web root directory:

mv nextcloud /var/www/html/nextcloud

Step 5: Set Permissions

Set the correct permissions to ensure Nextcloud can write to the necessary directories:

sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 755 /var/www/html/nextcloud

Step 6: Configure Apache

Create a new Apache configuration file for Nextcloud:

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

Add the following configuration:

ServerAdmin admin@example.com DocumentRoot /var/www/html/nextcloud ServerName your_domain.com ServerAlias www.your_domain.com Options +FollowSymlinks AllowOverride All Require all granted Dav off SetEnv HOME /var/www/html/nextcloud SetEnv HTTP_HOME /var/www/html/nextcloud ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

Enable the new configuration and rewrite module, then restart Apache:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 7: Set Up the Database

Log in to your MySQL shell and create a database for Nextcloud:

mysql -u root -p

Enter the following commands in the MySQL shell:

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

Step 8: Complete the Installation

Open your web browser and navigate to your server’s domain (e.g., http://your_domain.com). Follow the on-screen instructions to complete the Nextcloud installation, entering your database details when prompted.

Conclusion

You have successfully installed Nextcloud on the latest version of Ubuntu. You can now use Nextcloud to manage and share your files securely.