Skip to main content

How to install Nextcloud on AlmaLinux 8, 9

Updated today

Introduction

Nextcloud is an open-source program with which you can organize your own cloud storage.

An important feature of using Nextcloud as a cloud storage is data security. The information is stored on a server under your control, and you yourself can set up protection and differentiate access rights.

In addition, there are over a hundred applications that can be integrated and used with Nextcloud.

Prerequisites

To install Nextcloud you will also need the following software:

Installation guide

Import GPG key repository

Run the following command to install updated GPG keys on AlmaLinux:

rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux

1. Update the system

To update system, run the following command:

yum update

2. Enabling extensions

You also need to enable some extensions. Run this command:

yum install php-xml php-cgi php-cli php-mysql php-mbstring php-gd php-curl php-zip wget zip

3. Downloading installation files

In this guide, we are installing Nextcloud version 28, but you can install any other version. To select the version you want, go to the Nextcloud page and copy the link of the selected version (click the selected version and select "copy link"):

Then run the command wget with this link as in this example:

wget https://download.nextcloud.com/server/releases/nextcloud-28.0.3.zip

4. Unzip the downloaded file

To unpack the downloaded archive, you first need to install the 'unzip'(if you have not already done so):

yum install unzip

Once 'unzip' installed, you can extract installation files by running this command:

unzip nextcloud-28.0.3.zip

Move extracted folder to the /var/www/html/

mv nextcloud/ /var/www/html/

Create directory to store Nextcloud files:

mkdir /var/www/html/nextcloud/data
chown apache:apache -R /var/www/html/nextcloud/data

Finally, give the apache user the required ownership:

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

5. Create configuration file for Nextcloud

Create Apache configuration file for Nextcloud by running the following command:

vi /etc/httpd/conf.d/nextcloud.conf

In this file, enter the following lines and make sure to change "serverhostname" to your server hostname and "[email protected]" to your actual email:

<VirtualHost *:80> 
ServerName serverhostname
ServerAdmin [email protected]
DocumentRoot /var/www/html/nextcloud
<directory /var/www/html/nextcloud>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</directory>
</VirtualHost>

After that, restart Apache web server:

systemctl restart httpd

6. Open ports

Allow ports 80 (http) and 443 (https) in iptables by running the following commands:

iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT

Then save the changes:

iptables-save

At this point, Nextcloud is already enabled on your server and you can open it by entering your server's hostname as the URL in your web browser (http://your_server_hostname).

However, the connection is not secure (HTTP), so if you want to access Nextcloud via HTTPS, follow the next steps.

Please note: If firewalld is enabled on your server, you will need to allow HTTP and HTTPS on it as well:

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https

Then reload firewalld:

firewall-cmd --reload

7. Configure Nextcloud With Let’s Encrypt SSL on AlmaLinux

First, install Certbot:

dnf install certbot python3-certbot-apache mod_ssl

Then run the following command to enable self-signed SSL/TLS certificates for localhost:

openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 365 -out /etc/pki/tls/certs/localhost.crt

Finally, run the last command to generate a certificate for your server hostname. Make sure to change your_server_hostname" and "[email protected]" to your actual hostname and email address:

certbot --apache --agree-tos --no-eff-email --redirect --hsts --staple-ocsp --email [email protected] -d your_server_hostname

9. Complete Nextcloud installation

Now you can navigate to your Nextcloud by visiting the hostname of your server in a web browser:

You should see the following page:

To complete the installation, you need to create a Nextcloud user. For that, enter the new user username and password:

After that, click on "MySQL/MariaDB" and enter the MySQL username, password, and database name (you need to have created a database to run Nextcloud). Click "Install" to complete the installation.

That's all. Now, you can manage your files via Nextcloud!

Did this answer your question?