Read in 3 minutes
How To Install and Configure Nextcloud with Apache on CentOS 7
Nextcloud is an open source, self-hosted file share and collaboration platform, similar to Dropbox. It comes bundled with media player, calendar and contact management.
Nextcloud is extensible via apps and has desktop and mobile clients for all major platforms.
This tutorial will walk you through the process of installing and configuring Nextcloud with Apache on a CentOS 7 system.
Before starting with the tutorial, make sure you are logged in as a user with sudo privileges.
Step 1: Creating MySQL Database
NextCloud can use SQLite, PostgreSQL or MySQL database to store all its data.
In this tutorial we will use MySQL as the database of choice.
If you already don’t have MySQL or MariaDB installed on your CentOS server you can install by following one of the instructions below:
Start by logging to to the MySQL shell by typing the following command:
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'change-with-strong-password'; FLUSH PRIVILEGES; EXIT;
Step 2: Installing PHP and Apache
Nextcloud is a PHP application. CentOS 7 ships with PHP 5.4 which is not supported by Nextcloud.
We will install PHP 7.2 from the Remi repository. The commands below will enable EPEL and Remi repositories:
sudo yum install epel-release yum-utils sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm sudo yum-config-manager --enable remi-php72
sudo yum install httpd php php-gd php-json php-mysql php-curl php-mbstring php-intl php-mcrypt php-imagick php-xml php-zip
Step 3: Configuring firewall
If you are running Firewall on your CentOS server, you’ll need to open HTTP (
80) and HTTPS (
You can do that by running the following commands:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
Step 4: Downloading Nextcloud
wget -P /tmp https://download.nextcloud.com/server/releases/nextcloud-15.0.0.zip
At the time of writing this article, the latest version of Nextcloud is version 15.0.0.
Once the download is complete, extract the archive to the /var/www directory:
sudo unzip /tmp/nextcloud-15.0.0.zip -d /var/www
Set the correct ownership so that the Apache web server can have full access to the Nextcloud’s files and directories:
sudo chown -R apache: /var/www/nextcloud
Step 5: Configure Apache
Open your text editor and create the following Apache configuration file.
sudo nano /etc/httpd/conf.d/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/" <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory>
Activate the changes by restarting Apache service:
sudo systemctl restart httpd
Step 6: Installing Nextcloud
Now that Nextcloud is downloaded and all necessary services are configured open you browser and start the Nextcloud installation by visiting your server’s domain name or IP address followed by
You will be presented with the Nextcloud setup page.
Enter your desired admin username and password and the MySQL user and database details you previously created.
Click on the
Finish setup button and once the installation process is completed you will be redirected to the Nextcloud dashboard logged in as admin user.
You have learned how to install and configure Nextcloud on your CentOS 7 machine. If you have a domain name associated with your Nextcloud server, you can follow this guide and secure your Apache with Let’s Encrypt.
To find more information about how to manage your Nextcloud instance visit the Nextcloud documentation page.
If you have any question, please leave a comment below.