How to Install Nextcloud on CentOS 7

Prerequisites

we need to enable EPEL repository to get dependent packages.

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

output:

[[email protected] ~]# rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Preparing...                          ################################# [100%]

rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

output:

[[email protected] ~]# rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Preparing...                          ################################# [100%]

Install the Apache server and other utilities.

yum install -y httpd wget bzip2

output:

[[email protected] ~]# yum install -y httpd wget bzip2
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirror.webruimtehosting.nl

Install the PHP and its extensions using the yum command.

yum install -y php71w php71w-common php71w-gd php71w-intl php71w-mbstring php71w-mcrypt php71w-mysqlnd php71w-process php71w-xml php71w-cli php71w-pdo

output:

[[email protected] ~]# yum install -y php71w php71w-common php71w-gd php71w-intl php71w-mbstring php71w-mcrypt php71w-mysqlnd php71w-process php71w-xml php71w-cli php71w-pdo
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirror.nl.datapacket.com
* epel: mirror.infonline.de
* extras: mirror.oxilion.nl
* remi-php70: remi.mirror.karneval.c

Insatll MariaDB/MySQL as a database for ownCloud

yum -y install mariadb-server mariadb

output:

[[email protected] ~]# yum -y install mariadb-server mariadb
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirror.1000mbps.com
* epel: mirror.infonline.de
* extras: mirror.oxilion.nl

Download and Setup

cd /tmp/ 
wget https://download.nextcloud.com/server/releases/latest.tar.bz2

output:

[[email protected] ~]# cd /tmp/ 
[[email protected] tmp]# wget https://download.nextcloud.com/server/releases/latest.tar.bz2
--2019-01-14 10:12:43--  https://download.nextcloud.com/server/releases/latest.tar.bz2
Resolving download.nextcloud.com (download.nextcloud.com)... 88.198.160.133
Connecting to download.nextcloud.com (download.nextcloud.com)|88.198.160.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 36224830 (35M) [application/x-bzip2]

Extract the Nextcloud archive using the tar command.

tar -jxvf latest.tar.bz2

output:

nextcloud/3rdparty/aws/aws-sdk-php/src/CloudWatchEvents/Exception/CloudWatchEventsException.php
nextcloud/3rdparty/aws/aws-sdk-php/src/CodeCommit/
nextcloud/3rdparty/aws/aws-sdk-php/src/CodeCommit/Exception/
nextcloud/3rdparty/aws/aws-sdk-php/src/CodeCommit/Exception/CodeCommitException.php
nextcloud/3rdparty/aws/aws-sdk-php/src/CodeCommit/CodeCommitClient.php
nextcloud/3rdparty/aws/aws-sdk-php/src/DAX/

Move the extracted files to Apache’s document root and then create a data directory to hold the user data.

mv nextcloud /var/www/html/ 
mkdir /var/www/html/nextcloud/data

output:

[[email protected] tmp]# mv nextcloud /var/www/html/ 
[[email protected] tmp]# mkdir /var/www/html/nextcloud/data

Set the ownership of the files inside the NextCloud directory so that apache user can write the data into it.

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

output:

[[email protected] tmp]# chown -R apache:apache /var/www/html/nextcloud/

Start the Apache and MariaDB/MySQL service

systemctl start httpd
systemctl start mariadb

output:

[[email protected] tmp]# systemctl start mariadb
[[email protected] tmp]# systemctl start httpd

Enable both Apache and MySQL/MariaDB service to start automatically at system start-up.

systemctl enable httpd
systemctl enable mariadb

output:

[[email protected] tmp]# systemctl enable httpd
[[email protected] tmp]# systemctl enable mariadb

Create Database

mysql -u root -p

output:

[email protected]:~# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2

create database nextclouddb;

output:

MariaDB [(none)]> create database nextclouddb;
Query OK, 1 row affected (0.00 sec)

grant all on nextclouddb.* to 'nextcloud'@'localhost' identified by '[email protected]';

output:

MariaDB [(none)]> grant all on nextclouddb.* to 'nextcloud'@'localhost' identified by '[email protected]';
Query OK, 0 rows affected (0.00 sec)

quit

Firewall

FirewallD:

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

output:

[[email protected] ~]# firewall-cmd --permanent --add-service=http
success
[[email protected] ~]# firewall-cmd --permanent --add-service=https
success
[[email protected] ~]# firewall-cmd --reload
success

IPtables:

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

output:

[[email protected] ~]# iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
[[email protected] ~]# iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
[[email protected] ~]# service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

Configure NextCloud

From your web browser, open the URL: http://IP_Address/nextcloud

From here, you will have to configure and setup the nextcloud using the web interface.