In this guide, we are going to set up NextCloud on a Centos 8 server hosted with Nginx and php (LEMP stack). We will be using Mysql 8 and PHP 7.4 for this guide.This will also work for RHEL derivatives like Alma Linux 8, Rocky Linux 8 and RHEL 8.
Nextcloud is an Open Source suite of client-server software for creating and using file hosting services. It is a a free self-hosted cloud storage solution similar to Dropbox, Google Drive, etc. With Nextcloud, you don’t have to worry about the pricey alternatives and since you will host your own files, you don’t have to worry about privacy or someone collecting your data.
NextCloud can be installed on a private home server or a virtual private server in the cloud. Files can then be uploaded and then synced to a local desktop, laptop or even a smartphone. This way you have full control of your data.
Features of NextCloud
- NextCloud has sync clients for Linux, Mac OS, Windows, Android and IOS
- End to end encryption – files are encrypted while being uploaded to the server
- NextCloud is free and Open Source
- Can be integrated with an online office suite (Collobora, OnlyOffice) so you can create and edit your doc, ppt, xls files directly from NextCloud.
- The app store contains hundreds of apps to extend functionality (like calendar app, notes-taking app, video conferencing app, etc).
Related Content:
Prerequisites
To follow along this guide, ennsure that you have:
- An up to date Rocky Linux/RHEL 8 based Server
- Internet access
- Root acces to the server or sudo access
Ensure that the server packages are up to date
Let us make sure that our server packages are up to date with this command:
|
|
Disable SELinux
Next, let us disable SELinux. We are going to set SELinux to permisive. Edit this file:
|
|
Then update this line:
|
|
Installing mysql
Mysql is a popular relational managementn system. It is available in the default repositories as mysql-server
.
Install it with this command:
|
|
You will need to start and enable to ensure its always started when the server starts.
|
|
Once the mysql service is running, you need to secure it. Mysql provides a commandline utility that will do that:
|
|
The above command will take you throuh prompts to secure and set a root password for the mysql instance.
Check more info on Installing and setting up mysql in this guide here.
Creating mysql user for NextCloud
It is always recommended to have a dedicated user for each app that connects to the DB. Check out this guide on managing mysql permissions here. We will set up a database, user and password to be used by nextcloud:
Connect to mysql server:
|
|
After Supplying your password, enter the following to the mysql prompt:
|
|
Now that we have configured our mysql connection, lets go to the next section where we install and configure PHP and Nginx.
Installing PHP
NextCloud works fine with PHP 6.4. To install php 7.4, we need to enable remi repository so we get the latest version.
Enable Remi repo with this command:
|
|
Enable php 7.4 using dnf module:
|
|
Then install php and dependancies
|
|
For more info on setting up Apache and PHP, check this guide here. Check out about the remi release here.
Installing Nginx
Next, let us install Nginx in our system. Use this command to install nginx
|
|
Start and check the status of Nginx
|
|
Active: active (running)
indicate that the service is now up and running.
Download and configure Nextcloud
Now that we have successfully configured the LEMP server in our system, let us download and set up NextCloud. You can get the latest version of NextCloud from the NextCloud installation page. Use this command to download the server NextCloud:
|
|
Now let us change into a directory path to serve NextCloud in /var/www
then extract the downloaded file there:
|
|
Nextcloud required a directory to keep its data. So create a data directory and set the proper permissions on nextcloud directory
|
|
Configure Nginx to serve NextCloud from a virtual host
We managed to download the NextCloud content to /var/www/nextcloud
. The next bit it to set up Nginx to serve it.
Let’s create virtual site in the directory that nginx serves content here /etc/nginx/conf.d
:
|
|
Add the following content:
|
|
Updating PHP Configuration
Next let us take care of some php config. We are using php-fpm to serve our php content. It is configured to work with apache by default so let’s update the user and group in the file /etc/php-fpm.d/www.conf
to nginx.
Edit the file
|
|
Then update these
|
|
Let us also change the session directoory for us to login. Update PHP session directory to be owned by nginx:
|
|
Once the abve changes have been made, we need to restart the nginx server and the php-fom server. Use these commands in the terminal to achieve that.
|
|
Accessing Nextcloud from the web url
Then head to your set domain, http://nextcloud.citizix.com/nextcloud
for me. You will be asked to create the user account.
- Enter the username and password to be using for the new user.
- Then enter the Database Details
After that Click Finish. You will be redirected to the login page where you will use the details for the created user to login. On Successful login you will get the Dashboard.
Conclusion
In this guide, we managed to set up LEMP on Rocky Linux 8 or RHEL based Server to serve Next cloud.