Menu Close

Installing NextCloud 17 on CentOS 7

Step 1: Yum update

  • # yum update

Step 2 : Install Web Server

Install Apache Web Server

  • # yum install httpd

Enable Apache to boot and start the service

  • # systemctl enable httpd
  • # systemctl start httpd

Step 3 : Install PHP 7

By default CentOS 7 ships with PHP 5.4 which is not supported for NextCloud17

  • Check PHP version # php -v or # rpm -qa | grep php

To install PHP 7, you have to install and enable EPEL and Remi repository on CentOS 7 system first:

  • # yum install epel-release
  • # rpm -Uvh

Enable Remi PHP 7 repo:

  • # yum install yum-utils
  • # yum-config-manager –enable remi-php70

Install PHP 7 and required modules

Verify PHP version # php -v

Step 4 : Install MariaDB 5.5 server

Enable MariaDB repository – Create a repository file named MariaDB.repo and add the below content:–centos7&mirror=osuosl&version=10.4

  • # vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.3 CentOS repository list - created 2018-05-25 19:02 UTC
name = MariaDB
baseurl =

Install MariaDB 5.5 server and client

  • # yum install mariadb-server mariadb-client
  • # systemctl start mariadb
  • # systemctl enable mariadb

Run the following to create root password, remove the test database, remove the anonymous user and reload the priviledges:

  • # mysql_secure_installation
 [root@aliyun /]# mysql_secure_installation  


 In order to log into MariaDB to secure it, we'll need the current
 password for the root user.  If you've just installed MariaDB, and
 you haven't set the root password yet, the password will be blank,
 so you should just press enter here.
 Enter current password for root (enter for none): 
 OK, successfully used password, moving on...
 Setting the root password ensures that nobody can log into the MariaDB
 root user without the proper authorisation.
 Set root password? [Y/n] Y
 New password: 
 Re-enter new password: 
 Password updated successfully!
 Reloading privilege tables..
  ... Success!
 By default, a MariaDB installation has an anonymous user, allowing anyone
 to log into MariaDB without having to have a user account created for
 them.  This is intended only for testing, and to make the installation
 go a bit smoother.  You should remove them before moving into a
 production environment.
 Remove anonymous users? [Y/n] y
  ... Success!
 Normally, root should only be allowed to connect from 'localhost'.  This
 ensures that someone cannot guess at the root password from the network.
 Disallow root login remotely? [Y/n] y
  ... Success!
 By default, MariaDB comes with a database named 'test' that anyone can
 access.  This is also intended only for testing, and should be removed
 before moving into a production environment.
 Remove test database and access to it? [Y/n] y
  - Dropping test database...
  ... Success!
  - Removing privileges on test database...
  ... Success!
 Reloading the privilege tables will ensure that all changes made so far
 will take effect immediately.
 Reload privilege tables now? [Y/n] y
  ... Success!
 Cleaning up...
 All done!  If you've completed all of the above steps, your MariaDB
 installation should now be secure.
 Thanks for using MariaDB! 

Step 5 : Create a database

# mysql -uroot -p -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
# mysql -uroot -p -e "GRANT ALL on nextcloud.* to nextcloud@localhost identified by 'password'"
# mysql -uroot -p -e "FLUSH privileges"

Step 6 : Configure Web Server

Create a virtual host configuration file for the domain to host NextCloud

  • # vim /etc/httpd/conf.d/
<VirtualHost *:80>

DocumentRoot /var/www/html/nextcloud

<Directory /var/www/html/nextcloud>
Options +FollowSymlinks
AllowOverride All

<IfModule mod_dav.c>
Dav off

SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud

ErrorLog /var/log/httpd/nextcloud-error_log
CustomLog /var/log/httpd/nextcloud-access_log common


Download NextCloud 17 from office website

  • # wget
  • # unzip /var/www/html
  • create a data directory # mkdir /var/www/html/nextcloud/data

Set permission to apache user and restart httpd

  • # chown -R apache:apache /var/www/html/nextcloud
  • # systemctl restart httpd.

Continue the setup via web installation on

Leave a Reply

Your email address will not be published. Required fields are marked *