How to Install NextCloud on CentOS 8

NextCloud is an open-source, on-premise file share and collaborative platform that allows you to save your files and access them across multiple devices such as PCs, smartphones, and tablets.

As a popular self-hosting platform that works much like DropBox, it allows you to seamlessly collaborate on various projects, manage your calendar, send and receive emails as well as make video calls.

In this guide, you will learn how to install NextCloud on CentOS 8.

Prerequisites:

Since we will be accessing NextCloud via a browser, it’s crucial to ensure that the LAMP stack is already installed on CentOS 8. LAMP is short for Linux, Apache, MySQL / MariaDB and PHP.

Step 1: Install Additional PHP Modules

Some requisite PHP modules are required for NextCloud to function as expected. Install them as shown below.

$ sudo dnf install php-mysqlnd php-xml php-zip  php-curl php-gd php-intl php-json php-ldap php-mbstring php-opcache 
Install PHP Modules in CentOS 8
Install PHP Modules in CentOS 8

Step 2: Create a NextCloud Database

After installing the necessary PHP modules, create a database that will contain NextCloud’s data by log in to the MariaDB database engine using the command below and provide the password.

$ mysql -u root -p

Upon logging in, create a database and a database user for NextCloud using the commands below.

MariaDB [(none)]> CREATE DATABASE nextcloud_db;
MariaDB [(none)]> GRANT ALL ON nextcloud_db.* TO ‘nextcloud_user’@’localhost’ IDENTIFIED BY ‘StrongP@ssword’;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Create NextCloud Database
Create NextCloud Database

Step 3: Install NextCloud on CentOS 8

The next step requires you to download NextCloud zipped file from NextCloud’s official site. By the time of writing down this guide, the latest version of NextCloud is 18.0.1.

To download NextCloud, run the following wget command.

$ sudo wget https://download.nextcloud.com/server/releases/nextcloud-18.0.1.zip

Unzip the file to the /var/www/html/ path.

$ sudo unzip nextcloud-18.0.1 -d /var/www/html/

Next, create a directory to store the admin user data.

$ sudo mkdir -p /var/www/html/nextcloud/data

Then modify NextCloud’s directory permissions so that the Apache user can append data into it.

$ sudo chown -R apache:apache /var/www/html/nextcloud/

Step 4: Setting Up SELinux and Firewall for NextCloud

You need to make a few configurations for SELinux so that it can handle Nextcloud without any problems. So run the commands below.

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data'
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?'
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?'
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/3rdparty(/.*)?'
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.htaccess'
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini'
$ sudo restorecon -Rv '/var/www/html/nextcloud/'

To allow external users to access NextCloud from your server, you need to open the webserver port 80. So run the commands below.

$ sudo firewall-cmd --add-port=80/tcp --zone=public --permanent
$ sudo firewall-cmd --reload

Step 5: Finalizing the NextCloud Installation

To complete NextCloud setup, launch your browser and browse the server’s IP address a shown.

http://server-IP/nexcloud

Create an Admin username and password.

Create NextCloud Admin Account
Create NextCloud Admin Account

Next, click on ‘Storage and database’. Select ‘MariaDB’ as the preferred database engine and fill in the database details.

Set NextCloud Database Settings
Set NextCloud Database Settings

The database details have been filled as shown below.

NextCloud Database Settings
NextCloud Database Settings

Finally, click on the ‘Finish’ button to complete the setup.

Finish NextCloud Setup
Finish NextCloud Setup

This takes you to the login page. Provide the username and password and hit ‘ENTER’ or click on the ‘Login’ button.

NextCloud Admin Login
NextCloud Admin Login

A brief walkthrough about NextCloud will be given in a slide format if you are logging in for the first time. Feel free to scroll to the right for more tips.

A Brief About NextCloud
A Brief About NextCloud

And finally, close the window to give you access to the dashboard.

NextCloud Admin Dashboard
NextCloud Admin Dashboard

And this brings us to the end of this guide. You can now backup, sync and share files with your friends and colleagues on NextCloud. Thanks for coming this far. We hope this guide was inspiring.

If you read this far, tweet to the author to show them you care. Tweet a thanks
James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 thought on “How to Install NextCloud on CentOS 8”

  1. You should add the following command to the selinux section for users with remote databases.

    # setsebool -P httpd_can_network_connect_db on
    
    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.