Nextcloud is one of the most popular free and open-source self-hosted file sync and sharing applications. You can use it to store your personal files, contacts, pictures, music, and much more and it allows you to access them or share them with your friends at any time. It is a popular alternative to another widely used file hosting application called ownCloud. In this tutorial, we will show you how to install the latest version 14 of Nextcloud on CentOS.
Table of Contents
- CentOS 7
- SSH access with root privileges
- PHP 7 or above
Step 1: Log in to your server via SSH:
# ssh root@IP_Address -p Port_number
Before starting, enter the command below to check whether you have the proper version of CentOS installed on your machine:
# cat /etc/redhat-release
which should give you the underneath output:
CentOS Linux release 7.5.1804 (Core)
Step 2: Update the system
Make sure your server is fully up to date:
# yum update
If your system has not been updated for a while, it will take a few minutes to complete.
# yum install -y epel-release
Step 3: Install Web Server
In this step, you can choose whether you want to install Apache or Nginx.
Install Nginx web server
# yum install nginx
Enable Nginx to start on boot and start the service using:
# systemctl enable nginx # systemctl start nginx
Install Apache web server
If you would like to choose Apache instead of Nginx, you can skip the Nginx installation above then install Apache.
# yum install httpd
Enable Apache to start on boot and start the service using:
# systemctl enable httpd # systemctl start httpd
Step 4: Install PHP 7
The default PHP version on CentOS 7 is PHP 5.4 and Nextcloud 14 requires PHP 7 or above, in this step, we will install PHP version 7.
Install Remi and EPEL repository packages:
# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Enable Remi PHP 7 repo:
# yum-config-manager –enable remi-php70
and install PHP 7 and several PHP modules required by Nextcloud by executing the following command:
# yum install php php-mysql php-pecl-zip php-xml php-mbstring php-gd php-fpm php-intl
Now, let’s find the following strings in /etc/php-fpm.d/www.conf
user = apache group = apache
Replace the values with
user = nginx group = nginx
Then, change the permission for the PHP session directory, you need to skip this step if you want to use Apache instead of Nginx.
# chown -R root:nginx /var/lib/php/session/
Finally, restart php-fpm
# systemctl restart php-fpm
Step 5: Install MariaDB database server
# nano /etc/yum.repos.d/MariaDB.repo
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
# yum install MariaDB-server MariaDB-client
# systemctl start mariadb # systemctl enable mariadb # systemctl status mariadb
At this point, MariaDB is running and we are now going to create a password for the root user. Run the following command to create a root password, remove the test database, remove the anonymous user then reload the privileges.
Once created, you can test the password by invoking this command, you will be asked for the password:
# mysql -u root -p
Step 6: 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 'M0d1fyth15'" # mysql -uroot -p -e "FLUSH privileges"
Step 7: Configure Web Server
In the previous step, you chose a web server to install, now you will need to configure it.
If you want to use Nginx, please create a configuration file for the Nginx server block
Test Nginx configuration file, then restart the service
nginx -t systemctl restart nginx
Create a virtual host configuration file for the domain you want to use to host Nextcloud.
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot /var/www/nextcloud ServerName yourdomain.com ServerAlias www.yourdomain.com <Directory /var/www/html/nextcloud> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory> ErrorLog /var/log/httpd/nextcloud-error_log CustomLog /var/log/httpd/nextcloud-access_log common </VirtualHost>
Go to Nextcloud’s official website and download the latest stable release of the application
unpack the downloaded zip archive to the document root directory on your server
# unzip nextcloud-14.0.0.zip -d /var/www/ # mkdir /var/www/nextcloud/data # chown -R nginx: /var/www/nextcloud If you chose Apache, then you need to set the permission for Apache user # chown -R apache: /var/www/nextcloud You can now proceed with Nextcloud 14 installation via web installer at http://yourdomain.com, fill the blank as required, then click on the “Finish setup” button to finish it.
It is recommended to run the Nextcloud 14 in HTTPS mode. We will need to install an SSL certificate for this. In this step, we will show you how to install an SSL certificate from Letsencrypt.
# yum install certbot-nginx certbot-apache
You will be asked for your email address then you need to agree with the ToS to proceed with the certificate installation.
If there is no issue when requesting the certificate, Certbot will automatically edit your existing Nginx server block to install the certificate.
At this point, you can access your Nextcloud 14 installation on https://yourdomain.com
And that’s it, with the last step of this tutorial we have successfully installed Nextcloud 14 on your CentOs 7 and you can log in with the login credentials of your admin user. For more information, you can visit the official documentation of Nextcloud 14.
RoseHosting has been listed as a recommended Nextcloud hosting provider on Nextcloud.com. If you want to try our fully managed Nextcloud VPS hosting, use the coupon code: 50FIRST to get 50% off your first-month invoice. We have 7 days money-back guarantee. If you are one of our clients, you don’t have to install Nextcloud 14 on CentOS 7, you can simply ask our system administrators to install and configure your Nextcloud instance on CentOS or any other Linux OS. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post, on How To Install Nextcloud 14 on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.