Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

[CentOS 7/AlmaLinux 8] How to install Nextcloud on CentOS 7 and AlmaLinux 8


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.

In this tutorial, we will show how to install Nextcloud on RedHat based distributions (CentOS 7, AlmaLinux 8).


To install Nextcloud you will also need the following software:

Installation guide

Step for AlmaLinux 8 only: Import GPG key repository

This step is for AlmaLinux 8 only. Skip this step if you are installing Nextcloud on CentOS 7.

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

rpm --import

1. Update the system

To update system, run the following command:

yum update

2. Enabling extensions

You also need to enable some extensions.

On CentOS 7 run the following command:

yum -y install mod_ssl php php-cli php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo php-pecl-apcu php-pecl-apcu-devel php-ldap

On AlmaLinux 8 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:


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:


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

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:


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 next steps.

Please note: If firewalld 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 CentOS 7

This step is for CentOS 7 only. Proceed to the next step if you want to secure your Nextcloud connection in AlmaLinux 8.

First, install EPEL release and certbot:

yum -y install epel-release

yum -y install certbot

Then, run the following commands and make sure to change "your_server_hostname" and "[email protected]" to the actual hostname and email:

export DOMAIN="your_server_hostname"
export EMAIL="[email protected]"
certbot certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL --keep-until-expiring

Then open the Nextcloud configuration file:

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

And paste these lines (change "your_server_hostname" and "[email protected]" to your actual hostname and email):

<VirtualHost *:80>

ServerName your_server_hostname
ServerAdmin [email protected]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName your_server_hostname
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
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/your_server_hostname/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your_server_hostname/privkey.pem

After that restart the Apache:

systemctl restart httpd

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

This step is for AlmaLinux 8.

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 installation, you need to create a Nextcloud user. For that, enter the new user username and password:

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

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

Sign In or Register to comment.


Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch