Nextcloud is a free and open source file hosting solution. It is a promising alternative to other file hosting solutions like Owncloud. Nextcloud allows you to store and sync your files, mails, contacts from your mobile and desktop clients to nextcloud server. This guide will help you to understand Nextcloud and its installation process.
Requirements
Nextcloud does not require any special kind of hardware for installation you will only need a centos server with minimum 512 MB RAM so let’s get started with the installation process.
Updating the System
Before installing the Nextcloud on your server it is recommended to update the system. Use following command to do so.
yum -y update
Installing Apache and Dependencies
Once the system is updated, you can install the dependencies required. To install Nextcloud you will need to install the Apache web server along with MySQL and PHP with a few extensions.
Run the following command to install the Apache web server.
yum -y install httpd
Now you can start Apache and enable it to start at boot time, using the following commands.
systemctl start httpd.service
systemctl enable httpd.service
You can check the status of Apache web server using the following command.
systemctl status httpd
You should see following output:
[root@ip-172-31-26-79 ~]# systemctl start httpd.service
[root@ip-172-31-26-79 ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@ip-172-31-26-79 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2017-01-15 11:34:34 UTC; 1min 27s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 10540 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─10540 /usr/sbin/httpd -DFOREGROUND
├─10541 /usr/sbin/httpd -DFOREGROUND
├─10542 /usr/sbin/httpd -DFOREGROUND
├─10543 /usr/sbin/httpd -DFOREGROUND
├─10544 /usr/sbin/httpd -DFOREGROUND
└─10545 /usr/sbin/httpd -DFOREGROUND
Jan 15 11:34:34 ip-172-31-26-79 systemd[1]: Starting The Apache HTTP Server...
Jan 15 11:34:34 ip-172-31-26-79 systemd[1]: Started The Apache HTTP Server.
[root@ip-172-31-26-79 ~]#
To install MySQL, you will need to add the MySQL yum repository to your system, run the following command to do so.
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Once the repository is added, run the following command to install MySQL community server.
yum -y install mysql-community-server
Now you can start MySQL server and enable it to start at boot time like we have done before for Apache web server, using the following commands.
systemctl start mysqld.service
systemctl enable mysqld.service
You can check the status of MySQL using the following command.
systemctl status mysqld
You should see following result on your screen:
[root@ip-172-31-26-79 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2017-01-15 11:38:58 UTC; 58s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 10734 (mysqld)
CGroup: /system.slice/mysqld.service
└─10734 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Jan 15 11:38:52 ip-172-31-26-79 systemd[1]: Starting MySQL Server...
Jan 15 11:38:58 ip-172-31-26-79 systemd[1]: Started MySQL Server.
[root@ip-172-31-26-79 ~]#
During installation of MySQL, the installer automatically uses a random password for the MySQL root user, you can obtain the password using the following command.
grep 'temporary password' /var/log/mysqld.log
You will see the following output containing the current root password.
[root@ip-172-31-26-79 ~]# grep 'temporary password' /var/log/mysqld.log
2017-01-15T11:38:55.241864Z 1 [Note] A temporary password is generated for root@localhost: xqad.DMpX2Wy
[root@ip-172-31-26-79 ~]#
Now you can run the following command to harden the security of your MySQL server.
mysql_secure_installation
You will be asked about your current root password, enter the password obtained through the command above. Now it will prompt to change your root password, and provide y for all the questions asked.
After installation of MySQL you will need to install the PHP programming language. Nextcloud recommendeds PHP version 5.6 or 7. The default CentOS 7 repository contains PHP 5.4, thus you will need to add webtatic repository in your server. To install webtatic repository, you will need to add EPEL repository also so run following commands as shown below.
wget https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh epel-release.rpm
wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm rpm -Uvh webtatic-release.rpm
Now you can install any of the PHP versions. To install PHP v5.6 with required extensions, run the following command.
Remove the old version of PHP using this command yum remove php-common
Now you can install any of the PHP versions. To install PHP v5.6 with required extensions, run the following command.
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
To install PHP 7.0 with the required extensions, run the following command.
yum -y install php70w php70w-mysql php70w-dom php70w-xml php70w-gd php70w-fileinfo php70w-curl php70w-mcrypt php70w-zip php70w-mbstring
Once done you can check the PHP version using the following command.
php -v
You should see following output.
[root@ip-172-31-2-112 ~]# php -v
PHP 5.6.29 (cli) (built: Dec 10 2016 12:42:43)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
[root@ip-172-31-2-112 ~]#
To increase the PHP memory limit, edit the /etc/php.ini file with your favorite text editor.
nano /etc/php.ini
Scroll down to find the following lines.
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
Increase the memory_limit according to the memory available on your system.
Now you will need to restart Apache web server in order use PHP with Apache, run the following command to do so.
systemctl restart httpd
Now you will have to create the the database required to store the Nextcloud data. Login to MySQL shell using the following command and provide the required password when prompted.
mysql -u root -p
Now execute the following query to create a new database.
CREATE DATABASE nextcloud_data;
The above query will create a database named nextcloud_data. For the database you can use any name you prefer in the place of nextcloud_data. Make sure that you use semicolon at the end of each query as a MySQL query always ends with a semicolon. Once the database is created you can create a new user and grant the required permissions to the user for the database.
CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'StrongPassword';
The above query will create a user with username nextcloud_user. You can use any preferred username instead of nextcloud_user. Replace StrongPassword with a strong password.
Now provide the appropriate privileges to your database user over the database you have created. Run the following query to do so.
GRANT ALL PRIVILEGES ON nextcloud_data.* TO 'nextcloud_user'@'localhost';
Now run the following query to immediately apply the changes on the database privileges.
FLUSH PRIVILEGES;
Now you can exit from MySQL prompt using following command.
exit
Now you have successfully installed Apache web server with required PHP extensions and you have also created a database to store nextcloud data.
Download Nextcloud
Now you’ll have to download the latest version of nextcloud available in the market and run following command to download nextcloud on your server.
wget https://download.nextcloud.com/server/prereleases/nextcloud-11.0.1RC1.tar.bz2
If in case you don’t already have installed wget and bzip2 packages installed on your system then you can install them using these commands as shown below.
yum install wget bzip2 -y
Now extract the downloaded file to web server’s document root (/var/www/html), To do so run following command a shown below.tar -jxpvf nextcloud-11.0.1RC1.tar.bz2 -C /var/www/html/
Now we’ll have to change proper ownership and to do so run following command as shown below.
cd /var/www/html/
chown -R apache:apache nextcloud
Configure Firewall
Please run below given commands and set following new rules for firewall.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
Once done you’ll have to reload the firewalld service and to do so run following command.
firewall-cmd --reload
Now please disable SELinux temporarily using below shown command.
setenforce 0
Web Access of Nextcloud
Now access Nextcloud in your favorite web browser to complete the installation process and to do so please visit http://yourserverIP/nextcloud through your web browser then you’ll see a web page like this:
HP_NO_IMG/data/uploads/users/744ed2f1-2baa-42b2-b09d-ad15a2ae3934/1393623795.png” alt=” ” />
Now please provide the required details, set username as admin and password that you want to set. Finally please click on the Finish setup button.
By clicking on that button you’ll see a web page like this where you can get your apps, calendar, and contacts to sync you files or you can close this pop-up.
HP_NO_IMG/data/uploads/users/744ed2f1-2baa-42b2-b09d-ad15a2ae3934/147607411.png” alt=” ” />
HP_NO_IMG/data/uploads/users/744ed2f1-2baa-42b2-b09d-ad15a2ae3934/1976512343.png” alt=” ” />