How to install NextCloud on Ubuntu 20 LTS WSL Windows 10 OS | Part -1

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 LTS on Windows 

Step 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.
Now, go to open Microsoft Store on Windows 10 or use this Link to download Ubuntu 20.04 LTS Linux App.

Step 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.xx Linux app running on Windows subsystem for Linux. Just run the single Linux command given below:
sudo apt install apache2

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

Step 3. 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 install php php-common php-curl php-gd
sudo apt install php-json php-mbstring php-xml
sudo apt install php-zip
Some other Extensions for server performance including LDAP integration and external user authentication
sudo apt install php-ldap php-imap php-apcu php-memcached php-redis
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 PostgreSQL database they need this extension:

sudo apt install php-pgsql

Step 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

Step 5. Extract Downloaded zipped file

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/

Step 6. 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.sam
<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.


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

 

Step 7. Restart Apache

By default, Apache has the configuration file that points it to use the

sudo service apache2 stop
sudo service apache2 start

Step 8. 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.
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.

Open File Explorer.

Type \wsl$ in the address bar.
Continue to Part-2……..

Leave a Reply