How to Install ownCloud on Windows 10 WSL With Ubuntu

How to Install ownCloud on Windows 10 WSL With Ubuntu

This article shows how to install ownCloud on Windows 10 WSL (Windows Subsystem for Linux) with Ubuntu 18.04 | 20.04.

The ownCloud server is an open source and self-hosted cloud storage solution or platform for file hosting, sharing and multimedia playing. It is very similar to Dropbox, OneDrive and Google Drive. With the help of it, you can create your own cloud storage in your own environment with your own desired servers.

For more details about ownCloud, please check its official website.

With the help of WSL, you can easily install full Linux operating system in your Windows 10 system. You just need to enable WSL (Windows Subsystem for Linux) in your Windows, install a Linux OS, install and run ownCloud.


How to Install ownCloud on Windows 10 WSL

Simply follow below steps to install ownCloud on Windows 10 WSL with Nginx :

Step 1 : Enable WSL in Windows 10

First of all, you will need to enable WSL in your Windows system. To enable it, simply open PowerShell terminal as administrator.

Click on Start icon -> search for PowerShell -> right-click Windows PowerShell app -> choose to run as administrator.

Run-powershell

Next, run the command below in the Windows PowerShell console as show below:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

The command above will display a successful message similar as below:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844

Image Version: 10.0.19042.985

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Step 2 : Enable Virtual Machine Platform

Run the commands below from the same PowerShell console to enable the Virtual Machine platform in your Windows system:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

If you have Windows 10 version lower than 2004 in your system, use the commands below:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

Next, restart your computer for changes to apply. If you forget to start then the below command doesn’t work.

After restart of your computer, launch the PowerShell as administrator again and run the commands below to set WSL 2 as the default version of WSL:

wsl --set-default-version 2

Step 3 : Install Ubuntu in Windows 10

At this stage, WSL 2 is installed and ready to be used. So now you can easily install Linux operating system in your Windows 10 system.

Click the below button to download and install Ubuntu 20.04 LTS from Microsoft Windows store.

download-ubuntu

Click on the Get button to Download and Install Ubuntu. After installing Ubuntu, launch it from WSL environment.

After launching, it will install and prompt to create your account as show below :

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: studiesonline
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Use some troubleshooting commands when you get issues above. Run the below troubleshooting commands and launch Ubuntu again:

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Step 4 : Install Apache HTTP Server

Run the commands below to install Apache2 HTTP on Ubuntu server:

sudo apt update
sudo apt install apache2

Next, you can use the commands below to stop, start and restart Apache2 services:

sudo service apache2 stop
sudo service apache2 start
sudo service apache2 restart

For check if Apache2 server is installed and working, simply open your browser and type server IP or hostname.

If browser show result similar like below then Apache2 is installed and working properly.

http://localhost
apache-default-page

Step 5 : Install MariaDB Server

To install MariaDB database server, simply run the commands below:

sudo apt update
sudo apt-get install mariadb-server mariadb-client

Next, you can use the commands below to stop, start and restart MariaDB service :

sudo service mysql stop
sudo service mysql start
sudo service mysql restart

Now, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When you run the above command, it will prompted to answer the questions as show below:

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

For check if MariaDB is installed and working, run the command below:

sudo mysql -u root -p

When prompted, type the root password.

If you see the similar lines as below, then the MariaDB server was successfully installed.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 46
Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

Step 6 : Install PHP and Related Modules

To install PHP and related modules, run the command below:

sudo apt install php libapache2-mod-php php-imagick php-imap php-json php-ldap php-common php-pgsql php-ssh2 php-sqlite3 php-xml php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip

After installing the PHP and related modules, run the commands below to verify that PHP is installed and working:

php -v
Output
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

You can also test the PHP installation using a test php script. To do that, create a test PHP file called phpinfo.php in the server’s default home directory using command below.

sudo nano /var/www/html/phpinfo.php

Then simply copy and paste the below line into the test file and save it.

<?php phpinfo( ); ?>

Save the file and exit.

Restart the Apache2 using command below:

sudo service apache2 restart

Next, open your browser and browse to the server hostname or IP address followed by phpinfo.php as show below:

http://localhost/phpinfo.php

When test file is open, you see the PHP default page

Install phpMyAdmin on Windows 10 WSL-Apache-default-page

Step 7 : Create ownCloud Database

To create ownCloud database, first you will need to create a blank database for ownCloud. Simply run the command below to logon to MariaDB database server:

sudo mysql -u root -p

Next, create a database named  owncloud using command below:

CREATE DATABASE owncloud;

Now, run the command below to create a database user named ownclouduser :

CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'your_new_password_here';

Grant the newly created database user to the database by using command below:

GRANT ALL ON owncloud.* TO 'ownclouduser'@'localhost' WITH GRANT OPTION;

Next, save your changes and exit:

FLUSH PRIVILEGES;
EXIT;

Step 8 : Download ownCloud

To download the latest version of ownCloud, run the command below:

wget https://download.owncloud.org/community/owncloud-complete-20210326.zip -P /tmp
sudo unzip /tmp/owncloud-complete-20210326.zip  -d /var/www

At this time, the latest and stable version of ownCloud is version 10.7. To check the new and stable version of ownCloud, visit its Download page.

After that, you will need to allow www-data user to own the ownCloud directory by using command below:

sudo chown -R www-data:www-data /var/www/owncloud/
sudo chmod -R 755 /var/www/owncloud/

Step 9 : Configure ownCloud Site

To configure Apahce2 for OwnCloud site, create a new configuration file named owncloud.conf in the /etc/apache2/sites-available/ directory by running the commands below:

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

After create file, copy and paste the below content into the configuration file and save it. Replace the highlighted line with your own domain name :

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/owncloud/
     ServerName example.com
     ServerAlias www.example.com
  
     Alias /owncloud "/var/www/owncloud/"

     <Directory /var/www/owncloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/owncloud
        SetEnv HTTP_HOME /var/www/owncloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Next, run the command below to enable the VirtualHost including other modules:

sudo a2ensite owncloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

After that, restart the Apache2 using command below:

sudo service apache2 restart

Step 10 : Launch ownCloud

At this stage, ownCloud is installed and ready to use. To launch it, open your favorite web browser and browse to the server domain name http://example.com.

http://example.com

It will open the ownCloud setup wizard screen. At this screen, create admin account, typethe database details and Click on the Finish setup button to complete the installation process:

owncloud-steup

Next, login with the admin account created above.


That’s all

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top