In this guide, we are going to set up NextCloud on a Ubuntu 22.04 server hosted with Nginx, Mariadb and PHP (LEMP stack). We will be using Mariadb 10 and PHP 7.4 for this guide.
Nextcloud is an Open Source suite of client-server software for creating and using file hosting services. It is 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:
- How to Install and set up PHP and Nginx (LEMP) on Ubuntu 20.04
- How to install and configure NextCloud on Debian 11 and LEMP
- How to install and configure NextCloud on Centos 8 and LEMP
- How to install and Configure Mariadb 10 in Ubuntu 20.04
- How to Install and Set Up mysql 8 on Ubuntu 20.04
- How to Install and set up PHP and Nginx (LEMP) on Debian 11
Prerequisites
To follow along this guide, ensure that you have:
- An up to date Ubuntu 20.04 Server
- Internet access from the server
- Root access from the server or user with 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:
|
|
While at it, let us also install some dependencies that we will require
|
|
Installing Mariadb in Ubuntu 22.04
Mariadb is a popular Opensource relational management system. It is available in the default repositories as mariadb-server
.
Install it with this command:
|
|
Mariadb will be installed and started by default in Ubuntu 20.04. Check the status with this
|
|
To ensure that mariadb starts on boot, enable it with this systemd command:
|
|
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 Mariadb 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, let’s go to the next section where we install and configure PHP and Nginx.
Installing PHP 8.1 in Ubuntu 22.04
NextCloud works fine with PHP 8.1. This version is available in the default Ubuntu repos.
Then install php and dependancies
|
|
Confirm the installed php version:
|
|
For more info on setting up PHP and Nginx, check out this guide on How to Install and set up PHP and Nginx (LEMP) on Ubuntu 22.04.
Installing Nginx in Ubuntu 22.04
Next, let us install Nginx in our system. Use this command to install nginx
|
|
Nginx will be started by default. Check the status using this command:
|
|
Download and configure Nextcloud
Now that we have successfully configured the LEMP server in our system, let us download and set up NextCloud installer. Nextcloud provides a web installer that can be found in its site for web installer here.
First let us create our directory structure. We will create a directory /var/www/nextcloud
and download the installer there. Then we will make sure that the web user owns that directory:
|
|
7. 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
:
``sh sudo vim /etc/nginx/conf.d/nextcloud.conf
|
|
Once the above 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 installer from the web url
Then head to your set domain with the path for the set up, http://nextcloud.citizix.com/setup-nextcloud.php
for me to initiate nextcloud set up.
You will get a set up wizard that will take you through installing dependencies and setting up admin user and database connection credentials.
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 Ubuntu 22.04 to serve Next cloud.