Javascript required
Skip to content Skip to sidebar Skip to footer

How to Install Ubuntu and Remove Windows 10

Nextcloud is an Open source cloud server application for homes and businesses to host their files to access them from anywhere in the world using the internet. Here we will see the tutorial on how to install NextCloud on Ubuntu 20.04 LTS Focal fossa.

What is Next Cloud?

NextCloud is a fork of another open-source software called OwnCloud, however, it is now much popular. As I apprised above it is a server application that has the power to convert your small server such as Raspberry Pi into online storage; if you are so apprehended about your sensitive data to store them on services like Dropbox or Google Drive then you should try the Nextcloud.

Furthermore, you can use Nextcloud for video calls and edit documents with Collabora, which is based on LibreOffice.; along with support to recognize Microsoft Office formats such as DOC, DOCX, PPT, PPTX, and the Open Document Format (ODF).

Those are concerned about security, the Nextcloud provides industry compliance security features such as access control to files, protection against Bruteforce attacks, two-factor authentication, encrypted storage, and transfer of data.

requirements

The system requirements of NextCloud are not much high even we can run it on Raspberry pi 2.

  • Linux WSL App on WIndows- Ubuntu 20.04 LTS or later version such as Ubuntu 18.04 LTS
  • WSL should be enabled on your Windows 10 system.
  • Nextcloud needs a minimum of 128MB RAM  or recommended 512MB on your Server or Desktop,

For this tutorial, we will install the following things needed by the personal cloud server application.

  • Database: MySQL 5.7+ or MariaDB 10.2 or PostgreSQL 9.5+
  • Webserver: Apache with mod_php or php-fpm or nginx with php-fpm
  • Php: 7.3+

Steps to install Nextcloud on WSL Ubuntu 20.04 LTS

The steps given below will also work on the full-fledged Ubuntu 20.04 LTS focal fossa Linux system including other versions.

1. Enable WSL and install Ubuntu 20.04 App

Go to Windows 10 search and type "Turn Windows features on or off", as it appears, click on it to run. There scroll down and check the box given for "Windows subsystem for Linux" option and click the OK button. After enabling, the setup will ask to restart the system do it.

Enable WSL and install Ubuntu 20.04 App

Enable WSL

Now, go to open Microsoft Store on Windows 10 or use this Link to download Ubuntu 20.04 LTS Linux App.

2. Install Apache web server on WSL

Now, in the Windows 10 search box, type Ubuntu and run it.

As we know installing Apache is not a Sisyphean task on Ubuntu and the same goes for Ubuntu 20.04 Linux app running on Windows subsystem for Linux. Just run the single Linux command given below:

sudo apt install apache2

Ubuntu 20.04 WSL Apache web server installation

Ubuntu 20.04 WSL Apache webserver installation

Once the installation is completed, enable and check the Apache web server status. When it asks you to allow the Apache access through Windows 10 firewall, give it.

sudo service apache2 start
sudo service apache2 status

To check whether you can access the static page of Apache on Windows 10, open your browser and type: http://127.0.0.1

Apache on Windows 10

Apache on Windows 10

2. Install PHP on WSL (Windows 10)

The NextCloud is a PHP-based application, thus we also need to set up it along with some extensions which are required for the proper working server-side application.

By default, the PHP version available to install on via the official repository on Ubuntu 20.04 LTS is the latest stable version i.e PHP 7.4. Thus, here is the command which you need to execute.

        
sudo apt-get install -y php-{curl,gd,fpm,cli,opcache,mbstring,xml,zip,fileinfo,ldap,intl,bz2,json,imagick,redis,mysql,common}
sudo apt install libapache2-mod-php

Some other Extensions for server performance including LDAP integration and external user authentication

sudo apt install php-imap php-apcu php-memcached

If you are planning to use MySQL like we are going to do here then install its supported PHP extension:

sudo apt install php-mysql

In the same way, those who are planning to use the PostgreSQL database need this extension:

sudo apt install php-pgsql

3. Install MySQL for NextCloud on Ubuntu 20.04

Although you can use PostgreSQL, here we are about to install the popular MYSQL database for Nextcloud, thus the command for the same will be:

sudo apt install mysql-server

By default, the Ubuntu 20.04 LTS repository contains MySQL 8.0.

Enable MySQL Service

Once the installation is done, start the MySQL service:

sudo service mysql start
sudo service mysql status

If everything is ok! you will get something like this:

[email protected]:~$          sudo service mysql status          * /usr/bin/mysqladmin Ver 8.0.19-0ubuntu5 for Linux on x86_64 ((Ubuntu)) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.  Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.  Server version 8.0.19-0ubuntu5 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 1 min 49 sec  Threads: 2 Questions: 5 Slow queries: 0 Opens: 411 Flush tables: 3 Open tables: 27 Queries per second avg: 0.045 [email protected]:~$

Secure MySQL Installation

If you are planning to access and use it via a public network, then it is a good idea to secure the MySQL installation, first before creating users. Type:

sudo mysql_secure_installation

The above command will run a script to secure MySQL installation in which it gives you series of options such as enabling password validation component; removing anonymous users; disable remote root login; set a root password (blank by default); deleting demo database table and more…

Secure MySQL Installation

Secure MySQL Installation

You can know more about this on our detailed guide of MySQL installation on the Ubuntu 20.04 server.

Create a Database and user for NextCloud

"If you have secure and set a password for MySQL then use that one here"

sudo mysql -p

The command to create a database and user.

          CREATE DATABASE          db_name_here;

Note: Replacedb_name_here with the database name you want to give it.

CREATE USER 'h2suser'@'localhost' IDENTIFIED BY 'pass';

Grant rights to manage database activities to the user you have.

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON          db_name_here.          * TO 'h2suser'@'localhost';

Note: Replace the h2suserwith the username andpass with the password you want to assign.

exit

command to create Database and user for Mysql

commands to create Database and user for Mysql 8.0

4. Download NextCloud

By the time, we are writing this article the latest version of the Nextcloud server edition available to download was 18.04, thus we get the same for installation.

Visit the Download page, right-click on the Download button and copy the link.

Now, on your Ubuntu terminal type wget give space and paste the copied link. After hitting the enter button to download the NexxtCloud latest server version.

For example:

wget https://download.nextcloud.com/server/releases/nextcloud-x.x.xzip

The downloaded file of our was in zipped format thus, we also need a small program for that:

sudo apt install unzip

Now,

sudo unzip nextcloud*.zip

After inflating, move the file to Apache public folder

sudo mv nextcloud /var/www/html/nextcloud/

Create a data folder inside the copied folder

sudo mkdir /var/www/html/nextcloud/data

Set the permissions for the copied Nextcloud directory

sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/

5. Create nextCloud configuration file for Apache

By default, Apache has the configuration file that points it to use the files available under /var/www/html folder, we can edit that file to point it to our nextcloud directory inside the HTML folder. However, it is a better idea to create a separate configuration file, in case you are planning to host multiple websites.

sudo nano /etc/apache2/sites-available/nextcloud.conf

Copy-paste the following lines in that file.

Note: If you are want to use a custom domain then replaced your.server.com in the following with your domain name and update the DNS record for the same.

<VirtualHost *:80> ServerAdmin localhost DocumentRoot /var/www/html/nextcloud/  ServerName example.com ServerAlias www.example.com
<Directory /var/www/html/nextcloud/> Options +FollowSymlinks AllowOverride All Require all granted </Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>        

To save and exit the above nano editor, first press CTRL+O and then CTRL+X.

NextCloud Confgiuration file

Enable the newly created site:

sudo service apache2 reload
sudo a2ensite nextcloud.conf

Enable Apache Modules for Nextcloud

However, in most of the cases the following modules will automatically get enabled, yet to confirm run the below command:

sudo a2enmod rewrite headers env dir setenvif mime

Also, enable FPM support:

sudo a2enconf php*-fpm

Restart Apache

sudo service apache2 stop
sudo service apache2 start

6. Configuring NextCloud server on Ubuntu 20.04 WSL App (Windows 10)

Finally, we are at the final stage of the NextCloud setup using GUI. Open the browser on Windows 10 and type http:127.0.01/nextcloud

Note: If you get a message "Your data directory and files are probably accessible from the internet because the .htaccess file does not work. For information on how to properly configure your server, please see the documentation."

nextcloud error

Nextcloud error

To remove that follow the below steps. This appears because the .htaccess file of the Nextcloud would not be able to override the default Apache configuration thus we directly edit that.

sudo nano /etc/apache2/apache2.conf

Scroll down and find these lines:

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride          None          Require all granted </Directory>        

Now, replace the AllowOverride None to AllowOverride All

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride          All          Require all granted </Directory>

Finally, you will have an error-free NextCloud login screen.

7. Login Nextcloud

Finally, enter the username and password you want to register as an ADMIN account for NextCloud and then furnish the Database details. Last, click on the Finish Setup.

Create admin account and connect database

Create admin account and connect database

Finally, you will have the Dashboard:

NextCloud on Ubuntu 20.04 LTS WSL APP

NextCloud on Ubuntu 20.04 LTS WSL APP

Change Data Folder (Optional step)

By Default, whatever data we upload to NextCloud will go to its data folder that is at /var/www/html/nextcloud/data, it is in the root directory; so, Ubuntu WSL is in the C drive of Windows 10, therefore NextCloud will consume your C: Drive to store all the uploaded files. However, we can change that.

Here, I am going to move the data folder from my C: Drive to G: Drive of the system, so that, all the uploaded files will consume my G: Drive Space, and C: drive will remain free.

sudo cp -r /var/www/html/nextcloud/ /mnt/                          drive-name                              

Replace the drive-name with the one where you want to save your all files.

For example, I want it on G drive thus the command in my case was like this:

sudo cp -r /var/www/html/nextcloud/ /mnt/g

Now, edit the NextCloud Config file:

sudo nano /var/www/html/nextcloud/config/config.php

Find the line:

'datadirectory' ='/var/www/html/nextcloud/data'.

Replace the current directory location with the one where you have copied the data folder.

For example, I have copied it at /mnt/g/data. Thus, I use the same. You can see that in the below screenshot.

After that save it: CTRL+O and exit using CTRL+X.

Nextcloud Data directory

Nextcloud Data directory

Change the permission of your new data location:

sudo chmod 0770 /mnt/g/data
sudo chown -R www-data:www-data /mnt/g/data

Note: Replace /mnt/g/data with the location of your folder.

So, this was a quick tutorial on installing NextCloud on Ubuntu 20.04 WSL Linux app on Windows 10.

How to Install Ubuntu and Remove Windows 10

Source: https://www.how2shout.com/how-to/how-to-install-nextcloud-on-ubuntu-20-04-lts-wsl-windows-10.html