148 views
asked in Technology by

Step-by-Step Guide to Install and Configure Nextcloud on Ubuntu 24.04 LTS

1 Answer

answered by

To set up a file management server on Ubuntu with multi-user support (allowing file access and sharing based on individual usernames and passwords), we can use Nextcloud. It’s an open-source platform that provides file sharing, syncing, and collaboration with fine-grained access control. Below is a step-by-step guide to install and set up Nextcloud on Ubuntu:

Step 1: Update your system

Before installing any software, ensure your system packages are up to date:

sudo apt update && sudo apt upgrade

Step 2: Install Apache, MySQL, and PHP (LAMP Stack)

Nextcloud requires a LAMP (Linux, Apache, MySQL/MariaDB, PHP) server.

Install Apache

sudo apt install apache2

Install MySQL

    sudo apt install mysql-server
    sudo mysql_secure_installation

Install PHP and required modules Install PHP and the necessary modules required by Nextcloud:

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

Step 3: Download and Configure Nextcloud

Download Nextcloud Visit the Nextcloud download page to get the latest version of Nextcloud or use the following command to download the stable version:

   wget https://download.nextcloud.com/server/releases/latest.tar.bz2

Extract the file Unpack the downloaded archive:

    tar -xjf latest.tar.bz2

Move it to the web root directory Move the extracted Nextcloud files to the /var/www/html/ directory:

    sudo mv nextcloud /var/www/html/

Set the proper permissions Change ownership of the Nextcloud directory so that Apache can read and write to it:

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

Step 4: Configure Apache for Nextcloud

Create a new Apache configuration file for Nextcloud

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

Add the following content:

<VirtualHost *:80>
    DocumentRoot /var/www/html/nextcloud
    ServerName Your-IP-Address
    <Directory /var/www/html/nextcloud/>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the new configuration Enable the newly created configuration and Apache modules:

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

If getting error for 404 internal pages then issue due to htaccess.

run

    sudo a2enmod rewrite

Also change this in apache2.conf file located at /etc/apache2

    nano /etc/apache2/apache2.conf

    <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

Finally Restart Apache

   sudo service apache2 restart

Step 5: Configure MySQL for Nextcloud

Log into MySQL

    sudo mysql -u root -p

Create a Nextcloud database and user Replace admin@123 with a secure password:

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

Step 6: Finish Installation through the Web Interface

Open a web browser and navigate to http://your-domain.com or your server's IP address.

Complete the installation:

Enter your desired admin username and password.

For the database:

    Database user: nextclouduser
    Password: the password you set in Step 5. ie admin@123
    Database name: nextcloud
    Host: localhost

    Click Finish Setup.

Step 7: Configure HTTPS (Optional but Recommended)

To secure your Nextcloud server, it’s strongly recommended to enable HTTPS with Let’s Encrypt.

Install Certbot

    sudo apt install certbot python3-certbot-apache

Generate SSL certificate

    sudo certbot --apache -d your-domain.com

    Follow the prompts to configure HTTPS.

Step 8: Enable File Sharing and Multi-user Access

After completing the setup, Nextcloud allows users to:

Create individual user accounts.

Upload and share files either publicly or with specific users/groups.

Create shared folders.

Step 9: Optional: Install Nextcloud Apps

Nextcloud comes with many additional features and apps, such as:

    External storage support (Google Drive, Dropbox, etc.).

    Collaboration tools (document editing, calendars, etc.).

You can install these apps directly from the Nextcloud web interface.

Step 10: Enable Indexing of Files (Optional)

Nextcloud automatically indexes files uploaded by users, and you can easily navigate through your files in a hierarchical structure. You can configure the full-text search and enable file previews by installing relevant apps via the Nextcloud app store.

...