How To Install and Configure Nextcloud on Centos 7

In this guide, we want to teach you How To Install and Configure Nextcloud on Centos 7.

Nextcloud is open-source cloud storage software that allows you to back up and store files in the cloud from anywhere. Think Dropbox, Google Drive, or iCloud, except that you have complete control over where and how your files are stored.

The Nextcloud software essentially comes in two parts:

  • Server software provides the backend infrastructure needed to store your files in the cloud. This can be installed on your own computer in your own in your home (self-hosted) or on a remote server operated and maintained by someone else (hosted).
  • Client software is used to upload and access your files on a day-to-day basis. Client apps are available for Windows, macOS, Linux (many distros), iOS, and Android.

Install and Configure Nextcloud on Centos 7

To install Nextcloud on your Centos 7, you need some requirements.

Requirements

  1. You must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Centos 7.
  2. Set up a basic firewall with firewalld. You can check Set up a Firewall with firewalld on Centos 7.
  3. Install an Apache web server. To do this, you can follow our guide How To Install Apache on Centos 7.
  4. You need to have PHP 7.x or higher installed on your server. You can follow How To Install PHP 8.1 on Centos 7.
  5. You need a domain name that pointed to your server’s IP address.
  6. Also, you need to have MariaDB 10.x installed on your server. For this, you can visit How To Install MariaDB 10.8 on Centos 7.
  7. Finally, you must disable SELinux. You can follow our guide on How To Disable SELinux on Centos.

When you are done with these requirements follow the steps below to complete this guide.

Install PHP Extensions on Centos 7

Here you must install some PHP extensions on your server. To do this, use the following command:

sudo yum -y install mod_ssl 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

Create a Database for Nextcloud

At this point, you need to create a user and database for Nextcloud. First, log in to your MariaDB shell with the following command:

sudo mysql -u root -p

Then, from your MariaDB shell run the command below to create your user, here we named it nextcloud-user, remember to choose a strong password for it:

MariaDB [(none)]> CREATE USER 'nextcloud-user'@'localhost' IDENTIFIED BY "password";

Next, use the command below to create your database, here we named it nextclouddb:

MariaDB [(none)]> CREATE DATABASE nextclouddb;

Now you need to grant all the privileges to your Nextcloud DB with the command below:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextcloud-user'@'localhost';

Flush the privileges and exit from your MariaDB shell with the commands below:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Set up Nextcloud on Centos 7

At this point, you need to visit the Nextcloud official page and download it. Right-click on the Download for server from the Archive file and copy the link address.

Then, use the wget command to download Nextcloud on Centos 7:

wget https://download.nextcloud.com/server/releases/latest.zip

Unzip your downloaded file with the command below:

unzip latest.zip

Next, move your extracted file to the /var/www/html/ directory:

sudo mv nextcloud/ /var/www/html/

Now you need to create a data folder to store uploaded data in Nextcloud on Centos 7:

sudo mkdir /var/www/html/nextcloud/data

Set the correct ownership for your Nextcloud directory:

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

Create Apache Virtualhost file for Nextcloud

At this point, you need to create an Apache configuration file for NextCloud, to serve the file in case you are using the domain name or multiple websites are running on the same server.

Create and open your file with your favorite text editor, here we use vi:

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

Add the following content to your file:

<VirtualHost *:80>
ServerName example.com
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>

When you are done, save and close the file.

Restart Apache, to apply the changes:

sudo systemctl restart httpd

Now allow traffic on HTTP and HTTPs with the command below:

# sudo firewall-cmd --add-service={http,https} --permanent
# sudo firewall-cmd --reload

Access Nextcloud Web Interface

When all the above steps are completed you are ready to access the web interface for setting up NextCloud further on your Centos 7 system.

Open your web browser and type your server’s IP address or domain name:

http://your-server-ip-address
or
http://your-domain.com

You will see the following screen. You need to create an Admin user and password and then, you need to select MySQL/MariaDB as Database. Then enter the details of the Database you have created. In the end, click Install.

Nextcloud login screen

Then, you will see your Nextcloud dashboard.

Nextcloud dash

Conclusion

At this point, you learn to Install and Configure Nextcloud on Centos 7.

Hope you enjoy using it.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!