How to Install Nextcloud on Cloud Raya
Nextcloud is an open-source file-sync and file collaboration server which can be used for self-host. It also comes with an Enterprise Edition with enterprise support.
There are various methods to deploy Nextcloud :
- Manual install
- Docker image
- Web installer
This article will guide you on how to install Nextcloud in Cloud Raya using Manual install and Docker.
- Ubuntu 20.04 LTS (recommended)
- Red Hat Enterprise Linux 8 (recommended)
- Debian 10 (Buster)
- SUSE Linux Enterprise Server 15
- openSUSE Leap 42.1+
- CentOS 8
- MySQL 8.0+ or MariaDB 10.2+ (recommended)
- Oracle Database 11g (only as part of an enterprise subscription)
- PostgreSQL 9.6/10/11/12/13
- SQLite (only recommended for testing and minimal-instances)
- 7.4 (recommended)
This section will guide you on how to prepare your server before it will get installed with Nextcloud.
Assuming that you’ve already installed and configured the server with LEMP stack. However, if you haven’t, you can read the following articles:
For RHEL 8 / CentOS 8, make sure you have turned off SELinux.
Make sure you are already allowed port 80 and 443 globally in your Security Profile.
Getting Nextcloud Package
Get the latest Nextcloud package from here: https://download.nextcloud.com/server/releases/latest.tar.bz2
The above link will always point to the latest version of Nextcloud. But if you wish to install a specific version, you can find it here: https://download.nextcloud.com/server/releases/
Download the file using
cd curl -O https://download.nextcloud.com/server/releases/latest.tar.bz2
Then extract it to somewhere you wish, but by default it usually goes to
/var/www/, for Ubuntu 20.04:
cd tar -C /var/www -xvf latest.tar.bz2
For RHEL 8 / CentOS 8 , you will need to install
bzip2 package first:
dnf install bzip2 -y mkdir -p /var/www tar -C /var/www -xvf latest.tar.bz2
Next, you need to change the owner of the extracted Nextcloud folder. It must be matched with the user, defined in the web server settings. The default user on Ubuntu is
www-data, on RHEL 8 / CentOS 8 however, you will have to match the ownership as the web server you are using, either
chown -R www-data.www-data /var/www/nextcloud
Creating Database and Database User
Create a database and a database user for our Nextcloud instance.
mysql -uroot -p CREATE DATABASE nextclouddb; CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON nextclouddb.* TO 'dbuser'@'localhost'; FLUSH PRIVILEGES;
Install the following PHP 7.4 modules
apt install php7.4-common php7.4-curl php7.4-gd php7.4-gd php7.4-json php7.4-xml php7.4-mbstring php7.4-zip php7.4-mysql php7.4-gmp php7.4-ldap php7.4-bcmath php7.4-bz2 php7.4-imap php7.4-intl php7.4-apcu php7.4-imagick
RHEL 8 / CentOS 8
Don’t forget to enable PHP 7.4 module
dnf module enable php:7.4 dnf install php-common php-curl php-gd php-json php-xml php-mysqlnd php-mbstring php-zip php-gmp php-ldap php-bcmath php-bz2 php-intl php-apcu php-imagick
Modify the following lines in your
www.conf. For Ubuntu 20.04, it should be located in
/etc/php/7.4/fpm/pool.d/www.conf and for RHEL 8 / CentOS 8, it’s normally located in
;env[HOSTNAME] = $HOSTNAME ;env[PATH] = /usr/local/bin:/usr/bin:/bin ;env[TMP] = /tmp ;env[TMPDIR] = /tmp ;env[TEMP] = /tmp
Make sure those lines are uncommented.
Then restart php-fpm
systemctl restart php7.4-fpm
RHEL 8 / CentOS 8 :
systemctl restart php-fpm
Webserver – Nginx
You need to create a new server block for
nextcloud.conf which will serve Nextcloud files.
You’ll need to adjust the
server_name to match your own domain, and don’t forget to fix the SSL certificate and key location as well. You may also need to modify the php-fpm configuration, either you use a Unix socket or not.
For the certificate, you might want to put your commercially signed certificate or just use letsencrypt or even a self-signed one. Here’s how to generate self-signed certificate: LINK
Place the configuration on
/etc/nginx/sites-available then you’ll have to do this to activate it:
cd /etc/nginx/sites-enabled ln -s ../sites-available/nextcloud.conf .
RHEL 8 / CentOS 8
Put the configuration on
Then make sure that the configuration is correct and then reload
# check configurations nginx -t # reload nginx nginx -s reload
For RHEL 8 / CentOS 8, you might need to adjust your
php-fpm configuration if it’s not done yet. Find the below lines in
/etc/php-fpm.d/www.conf and change the values accordingly:
.. user = nginx group = nginx .. listen.owner = nginx listen.group = nginx ..
Later on, after Nextcloud installation, if you encounter a login redirect loop, you might want to check the ownership of
/var/lib/php/session to make sure it’s owned by
nginx group at least.
Open your browser and access your predefined domain. Mine was
https://cloud.example.lan. Then fill out the fields with the required data. For the Data Folder field, if you’re unsure, then just leave it untouched.
After filling out everything, then click Finish setup.
Wait for the installation and pay attention, do not close this tab / browser until the installation finishes.
Last thing to do is go to
https://YOUR_NEXCLOUD_DOMAIN/settings/admin/overview and do what the checklist says. It’s to make sure that your setup is complete.
Once you complete them, then your Nextcloud is ready to be used! Yay
Deploying Nextcloud using Docker image is a lot easier than the manual one. Basically, you’ll just need to pull the nextcloud image then run it. That’s it.
Assuming that you already have docker installed on your machine. But if you haven’t yet, you can read the tutorial via this link.
Here’s how to deploy Nextcloud using Docker
Docker Compose (recommended)
Copy paste the following snippet and save it as
--- version: "2.1" services: nextcloud: image: ghcr.io/linuxserver/nextcloud container_name: nextcloud environment: - PUID=1000 - PGID=1000 - TZ=Asia/Jakarta volumes: - /path/to/appdata:/config - /path/to/data:/data ports: - 443:443 restart: unless-stopped
Make sure you have adjusted the necessary values to match your environment.
Finally, run the below command to deploy it:
Using docker-compose is more preferred. You can easily make changes then redeploy the container. But if you prefer CLI way, here’s the snippet:
docker run -d \\ --name=nextcloud \\ -e PUID=1000 \\ -e PGID=1000 \\ -e TZ=Asia/Jakarta \\ -p 443:443 \\ -v /path/to/appdata:/config \\ -v /path/to/data:/data \\ --restart unless-stopped \\ ghcr.io/linuxserver/nextcloud
As always, you’ll have to modify some values to match you environment.
The installation process is the exact same as the manual approach.
If you need a thorough guide, you can read the official documentation here: https://docs.nextcloud.com/server/latest/admin_manual/contents.html