How to install Nextcloud on RHEL 8 / CentOS 8 server

In this article we will be performing an installation of Nextcloud. Nextcloud is a suite of client-server software to provide easy file sharing. The operating system to be used will be RHEL 8 / CentOS 8 server with MariaDB, PHP and Apache web-server.

In this tutorial you will learn:

  • How to install Nextcloud prerequisites
  • How to download and upzip Nextcloud source package
  • How to setup MariaDB database
  • How to setup Nextcloud

Successful Nextcloud installation on Red Hat Enterprise Linux 8

Successful Nextcloud installation on Red Hat Enterprise Linux 8

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL 8 / CentOS 8
Software Nextcloud 15.0.2 or higher
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to install Nextcloud on RHEL 8 / CentOS 8 server step by step instructions

  1. Install LAMP ( Linux, Apache, MariaDB and PHP ) server. Before you continue please follow our instructions on how to setup basic LAMP server on RHEL 8. Once ready move to the next step.
  2. Install all required Nextcloud prerequisites.

    The following command will perform a package installation of all Nextcloud prerequisites in addition to the PHP packages already installed in Step 1:

    # dnf install php-mbstring php-gd php-pecl-zip php-xml php-json unzip
    
    Nextcloud prerequisites on RHEL 8 Linux server

    Nextcloud prerequisites on RHEL 8 Linux server

  3. Download and install Nextcloud.

    Next step is to download a latest official Nextcloud Server source code package from the Nextcloud.com website. Perhaps the most convenient way to perform this task is by using the wget command.

    DOWNLOAD LATEST VERSION:
    $ wget https://download.nextcloud.com/server/releases/latest.zip
    

    Once the package is downloaded execute the below step to unzip the package into /var/www/html, create data directory and set appropriate directory permissions:

    # unzip latest.zip -d /var/www/html
    # mkdir /var/www/html/nextcloud/data
    # chown -R apache:apache /var/www/html/nextcloud/*
    # chcon -t httpd_sys_rw_content_t /var/www/html/nextcloud/ -R
    
    Extract Nextcloud source package and set appropriate directory permissions

    Extract Nextcloud source package and set appropriate directory permissions

  4. Create MariaDB database to be used with Nextcloud.

    The following commands will create MariaDB database named nextcloud and user admin with password pass:

    # mysql -u root -p
    mysql> CREATE DATABASE nextcloud;
    mysql> CREATE USER `admin`@`localhost` IDENTIFIED BY 'pass';
    mysql> GRANT ALL ON nextcloud.* TO `admin`@`localhost`;
    mysql> FLUSH PRIVILEGES;
    mysql> exit
    
    Setting up MariaDB SQL database for Nextcloud server on RHEL 8

    Setting up MariaDB SQL database for Nextcloud server on RHEL 8

  5. Start Nextcloud wizard and perform a final installation.

    Navigate your browser to your servers URL and fill up the Nextcloud setup form:

    Nextcloud wizard installation form on RHEL 8 Linux server

    Nextcloud wizard installation form on RHEL 8 Linux server. Once ready click on Finish setup button.

    WARNING
    In case you see the below error message make sure that you have correctly installed all Nextcloud prerequisites as per Step 2. Use the # php -m | grep -i PHP MODULE NAME command to list if the required PHP module is available.

    Internal Server Error
    
    The server encountered an internal error and was unable to complete your request.
    Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
    More details can be found in the webserver log.
    
  6. Your installation of Nextcloud should be now ready. Optionally install additional Nextcloud recommended PHP modules or secure your installation with mod_ssl.