NextCloud Install

1. Synopsis

This document describes the installation procedure for installing NextCloud on RHEL/CentOS. Original documentation can be found here.

2. Prerequisites

2.1. LAMP Stack

Refer here to LAMP Stack.

3. Setup Database

  1. Full instructions are here.

  2. Run the following 4 sql statements:

    $ mysql -u root -p (1)
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 70
    Server version: 10.3.28-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> CREATE USER 'NextCloudAdmin'@'localhost' IDENTIFIED BY 'aSecurePasswd1234'; (2)
    Query OK, 0 rows affected (0.001 sec)
    
    MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS NextCloudDB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    Query OK, 1 row affected (0.001 sec)
    
    MariaDB [(none)]> GRANT ALL PRIVILEGES on NextCloudDB.* to 'NextCloudAdmin'@'localhost'; (3)
    Query OK, 0 rows affected (0.001 sec)
    
    MariaDB [(none)]> FLUSH privileges;
    Query OK, 0 rows affected (0.001 sec)
    
    MariaDB [(none)]> quit; (4)
    Bye
    1 CREATE USER 'NextCloudAdmin'@'localhost' IDENTIFIED BY 'aSecurePasswd1234';
    2 CREATE DATABASE IF NOT EXISTS NextCloudDB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    3 GRANT ALL PRIVILEGES on NextCloudDB.* to 'NextCloudAdmin'@'localhost'; FLUSH privileges;
    4 quit;
  3. Launch the phpMyAdmin interface and log in with the root account that was set up during the MariaDB configuration:

     http://v-RedHat00/phpmyadmin

    phpMyAdmin-Login

4. Setup NextCloud in Apache

  1. Full instructions are here. You’ll need to scroll down halfway through the page to the Installing Nextcloud section.

  2. Download NextCloud .zip file from here.

  3. Place that downloaded zip file into /tmp.

  4. Go to the /tmp dir:

    cd /tmp
  5. Unzip the file:

    unzip nextcloud-*.zip
  6. Copy the content over to the root directory of Apache:

    sudo cp -R nextcloud/ /var/www/html/
  7. Create a data folder:

    sudo mkdir /var/www/html/nextcloud/data
  8. Grant the apache user read and write access to the nextcloud folder:

    sudo chown -R apache:apache /var/www/html/nextcloud
  9. Restart apache:

    sudo systemctl restart httpd.service
  10. Configure SELinux:

    semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?'
    semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?'
    semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?'
    semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.htaccess'
    semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini'
    semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/3rdparty/aws/aws-sdk-php/src/data/logs(/.*)?'
    
    restorecon -R '/var/www/html/nextcloud/'
    
    setsebool -P httpd_can_network_connect on

5. Run NextCloud Installation Wizard

  1. Full instructions are here.

  2. Launch the Installation Wizard interface:

    http://v-RedHat00/nextcloud
  3. Configure:

    1. admin account/password

    2. data directory (take the default)

    3. database connection

      Wizard-Admin-Account

    4. Click the Finish setup button.

6. Configure Reverse Proxy

6.1. Reverse Proxy NextCloud Configuration

  • At this point the Nextcloud interface is only accessible via hosts on the local Lan. We want to open this up to the internet.

  1. Full instructions are here.

  2. Edit the config.php file:

    sudo vi /var/www/html/nextcloud/config/config.php

    set the following values to the `$CONFIG = array `:

    'trusted_proxies'   => ['192.168.1.2'],
    'overwritehost'     => 'cloud.xackleystudio.com',
    'overwriteprotocol' => 'https',
    'overwritecondaddr' => '^192\.168\.1\.2$',
  3. Browse to: https://cloud.xackleystudio.com/nextcloud

6.2. Reverse Proxy IIS Configuration