How to install Owncloud server on Windows 10 (WSL)

The OwnCloud server is an open-source cloud storage solution with multimedia playing and file-sharing capabilities.  It can be installed on Linux platforms without any problem and it has to be for proper performance and stability. However, the users who are much familiar with Windows operating system install the Owncloud server using Windows’s IIS web server or third-party software like XAMMP or WAMP servers. But in this tutorial, we are not going to use any of them to install the Owncloud server on Windows 10 or any kind of virtual machine software like Virtualbox/Vmware. Instead of the traditional method, we use the Windows subsystem for Linux (WSL) for better stability and performance. The Linux environment app which we will use for it is Ubuntu.  Let’s see how to do this. The latest version of the OwnCloud while this tutorial was Owncloud 10.1.0.

Install Owncloud Server on Windows 10 via Ubuntu

Step 1: Enable the Windows subsystem for Linux (WSL)

To enable the Windows subsystem for Linux feature on Windows 10, go to Search box type “Turn Windows feature on or off” click on that as it appears and enables the WSL (Windows Subsystem for Linux) feature: For more info on this see: Enable the Windows subsystem for Linux feature

Enable the Windows subsystem for Linux (WSL)

Step 2: Install Ubuntu 18.04/20.04 Linux App

From Windows 10 search box or the program list search for the Microsoft store. When the store opened, search for Ubuntu 18 to download and install. After installing click on the Launch button which in return opens the Ubuntu bash or command screen from where we can use all Ubuntu commands except a few directly on Windows 10.

Microsoft store Ubuntu 18.04 app

Step 3: Install Apache, MySql/ MariaDB plus PHP on Windows 10

Before installing the Owncloud 10.1.0. we need to set up a web server environment a LAMP setup. Here is the command which we need to execute for installing Apache+PHP+MariaDB. Copy and paste the below one using the right mouse click and then hit the enter button.

sudo apt-get install apache2  
sudo apt-get install mysql-server mysql-client
sudo apt-get install php libapache2-mod-php php-mysql php-gd php-json php-curl php-xml php-zip php.mb
sudo apt-get -y install libmcrypt-dev

Owncloud also needs one more PHP extension i.e intl extension, so install that too.

sudo apt-get install php-intl

Step 4: Check your Windows 10 Apache installation

To check whether our Apache server is working, go to your  Windows 10 browser and type http://localhost/ or http://127.0.0.1/ or the IP address of your Windows 10 local machine.  You can find out the IP address by typing ifconfig. As you enter the IP address, the Apache testing page will open which means everything is fine and time to move to the next step.

Apache server for owncloud on Windows 10

Step 5: Download Owncloud server  

Here is the command to get the files required for setting up OwnCloud:

sudo apt install wget unzip
wget https://download.owncloud.org/community/owncloud-complete-latest.zip
unzip owncloud-complete-latest.zip
sudo mv owncloud/ /var/www/
sudo chown -R www-data:www-data /var/www/owncloud/

The above commands will automatically download and extract the Owncloud files under the Apache directory.


Step 6: Create an Owncloud configuration file for Apache

Now create an Owncloud configuration file using the below command:

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

And then add the following lines in it to points the Apache root directory towards the Owncloud.

Alias /owncloud "/var/www/owncloud/"

<Directory /var/www/owncloud/>
Options +FollowSymlinks
AllowOverride All

<IfModule mod_dav.c>
Dav off
</IfModule>

SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud

</Directory>

After adding the above lines press Crtl +O to write the files and then CTRL+X to save and exit.

Create an Owncloud configuration file for Apache

To tell the Apache about the Owncloud configuration we will create a reference or symlink using the below command:

ln -s /etc/apache2/sites-available/owncloud.conf /etc/apache2/sites-enabled/owncloud.conf

Step 8: Additional modules installation

Add these additional modules for proper Owncloud working.

sudo a2enmod headers env dir mime unique_id

After adding the modules restart the Apache server using the command:

sudo service apache2 restart

Step 9: Create a MySQL or MariaDB database for Owncloud

First of all stop and restart the MySQL/MariaDB:

sudo /etc/init.d/mysql stop

sudo /etc/init.d/mysql start

Now let’s create a MySQL user and database for OwnCloud:

sudo mysql

We are creating a database with the name owncloud you can use some other name if you want.

CREATE DATABASE owncloud;

Now create a user with a password and at the same time assign all rights of the above-created database to that. Here we are creating a user with the name h2smedia along with a password for the same. You can use your username and password:

CREATE USER 'h2smedia'@'localhost' IDENTIFIED WITH mysql_native_password BY 'my-strong-password-here';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON owncloud.* TO 'h2smedia'@'localhost';

Flush privileges operations:

FLUSH PRIVILEGES;

Exit the MySQL using the command:

exit
Create a MySQL or MariaDB database for Owncloud

Step 4 –Install, Setup, and Configuring ownCloud server on Windows 10

After performing all the above steps again go to the browser and type  http://localhost/owncloud/ or http://127.0.0.1/owncloud/  or the IP address of your Windows 10 local machine. Just like we did while checking the Apache is working or not above in this article.

However, this time you will see the Owncloud server setup and configuration screen rather than the Apache one.

Create an admin account for Windows 10 installed Owncloud. Just enter whatever user name along with a password for the same you want to assign Admin account.

Just after the admin account, you will see a storage and database option click on that and then MySQL/MariaDB tab. After that add the MySQL database details we have created above; which means database username its password and the database name which is owncloud in our case.

Finally, once you provided all the information to Owncloud, scroll down and click on the Finish Setup button.

setup owncloud server on Windows 10

Step 5: Login Owncloud server

The moment you click on the Finish setup button, the Owncloud will take a few seconds to authenticate all provided details and then will offer you a login page.

Login with the admin account you have created above.

As we know Owncloud also offers a client application that one can use on different operating systems to sync the files between PC/smartphone and Owncloud server.

The first screen that appears to you is dedicated to the same. Click on the one OS platform for you want to download the Owncloud client.

Get the apps to syn files on Owncloud to Windwos 10
Install Owncloud Server on Windows 10 via Ubuntu WSL

In this way, we can easily install the Owncloud server on Windows 10 for high performance and stability without using any XAMMP or WAMP-like software.

If you have found any difficulty while installing Windows 10 OwnCloud server, let us know, we will try to solve the same as soon as we could.

Other useful resources:


 

22 thoughts on “How to install Owncloud server on Windows 10 (WSL)”

  1. Hi,

    First of all thanks a lot for your article “How to install Owncloud server on Windows 10 (WSL)”. It is really appreciated.

    However I am having difficulties on installing Apache, MySql/ MariaDB plus PHP. Everytime I run the command line in ubuntu I get the following errors:

    Package php-imagick is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    Package php-smbclient is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    Package php-ssh2 is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    Do you know how I can fix this and find these packaged?

    Thank you.

    Best Regards

    Reply
    • We have updated the article now you can use the commands mentioned to install LAMP on Windows WSL for OWncloud…

      Reply
  2. Hey Rajkumar, thanks a LOT for this tutorial. I had to tell you this is one of the VERY few Linux howtos/tutorials that work exactly as described on the first try.
    Cheers!

    Reply
  3. Sorry man this does not work. I have used it step for step on Windows 10 Pro and for some reason I just can’t get it to work, I had tried it the first time, reinstalled windows and tried it again the second time and nothing works unfortunately. even get errors when running apache2

    Reply
  4. Thank you very much for the instructions. Tell me how to move the storage location to another local drive, for example D.

    Reply
  5. Thanks in advance for any reply!
    I’m having a problem. I can’t access to the rootfs folder. Can’t grant full access to my WSL user either.
    I think that is keeping from apache to read owncloud’s conf file and running the web gui.
    Thank you

    Reply
    • If you have sudo access then this should be a problem but as you said it is, so please try to reset the WSL distro you are using. And again install Owncloud.

      Reply
      • Thank you for the reply!
        Already did that. I did a reset and I unregistered it too. I’m doing it from windows server 2019 standard. I’m not using powershell. Done everything from the WSL shell.

        Reply
  6. Hi,

    Would you concider making a part two of this tutorial on enabling self signed SSL and how to harden apache, basically make the rig more secure with port forwarding on the router for access from outside.

    Reply
  7. Thank you, it worked! Would you be so kind as to update this article. Had problems with php-zip and php.mb errors on opening owncloud.

    Reply
  8. hi thank you for the tutorial
    i have a problem with the command line sudo apt-get install php-zip php.mb
    every time i get the following lines
    unable to locate package php-zip
    unable to locate package php.mb
    couldn t find any package by glob ‘php.mb’
    couldn t find any package by regex ‘php.mb’

    Reply
  9. hi i had problems with sudo service apache2 restart
    it keeps displaying this message
    * Restarting Apache httpd web server apache2
    [Tue Apr 18 18:50:52.618691 2017] [core:warn] [pid 546:tid 140453865195392] (92)Protocol not available:
    AH00076: Failed to enable APR_TCP_DEFER_ACCEPT

    Reply
  10. Great tutorial 🙂 It certainly helped me to get the owncloud server up and running.

    However, I did experience some issues during the installation, which I would like to share:

    1) Instead of Ubuntu 18.04, I installed Ubuntu 20.04 on WSL 2. As the only consequence I had to replace the string “Ubuntu_18.04” by “Ubuntu_20.04” in the commands to be applied.

    2) The installation of owncloud based on the box containing the folowing commands failed:
    sudo -i
    wget -nv https://download.owncloud.org/download/repositories/production/Ubuntu_20.04/Release.key -O Release.key
    apt-key add – /etc/apt/sources.list.d/owncloud.list
    apt-get update
    apt-get install owncloud-files

    More precisely, the command “apt-get update” failed, because the owncloud team has not signed the Ubuntu_20.04 release package. Luckily, the Debian_Unstable package has been signed, so as a workaround I replaced the string “Ubuntu_20.04” by “Debian_Unstable” in the commands above, and successfully managed to install owncloud.

    3) It was not possible to create a MySQL user and grant all privileges by the single command:

    GRANT ALL ON owncloud.* to ‘h2smedia’@’localhost’ IDENTIFIED BY ‘enter_your_password’;

    I had to replace it by the two commands:

    CREATE USER ‘h2smedia’@’localhost’ IDENTIFIED BY ‘enter_your_password’;
    GRANT ALL PRIVILEGES ON * . * TO ‘h2smedia’@’localhost’;

    4) I have created a powershell script startOwnCloud.ps1, which is started by the Task Scheduler when a user logs in. The action given in the Task Scheduler is:

    powershell.exe -ExecutionPolicy Bypass -windowstyle hidden \path\to\startOwnCloud.ps1

    Due to the use of WSL 2, Ubuntu is assigned its own IP at startup, and this IP is different from the one of the local machine. To gain access to owncloud based on the IP of the local machine, the owncloud ports 80 and 443 must be forwarded to the local machine (see https://dev.to/vishnumohanrk/wsl-port-forwarding-2e22).

    The first part of startOwnCloud.ps1 performs this port forwarding, while the second part starts the MySQL server and the Apache server.

    By having the script automatically started by the Task Scheduler when I log in, I ensure that the owncloud server is immediately available from the very beginning.

    The script is shown below. The forwarding part has been taken from the script provided in https://dev.to/vishnumohanrk/wsl-port-forwarding-2e22.

    startOwnCloud.ps1:

    # Forward the ownCloud ports, 80 and 443, from the WSL 2 IP to the local
    # machine and start the MySQL server and the Apache server.

    If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”)) {
    $arguments = “& ‘” + $myinvocation.mycommand.definition + “‘”
    Start-Process powershell -Verb runAs -ArgumentList $arguments
    Break
    }

    $remoteport = bash.exe -c “ifconfig eth0 | grep ‘inet ‘”
    $found = $remoteport -match ‘\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}’;

    if ($found) {
    $remoteport = $matches[0];
    }
    else {
    Write-Output “IP address could not be found”;
    exit;
    }

    $ports = @(80, 443);

    Invoke-Expression “netsh interface portproxy reset”;

    for ($i = 0; $i -lt $ports.length; $i++) {
    $port = $ports[$i];
    Invoke-Expression “netsh interface portproxy add v4tov4 listenport=$port connectport=$port connectaddress=$remoteport”;
    Invoke-Expression “netsh advfirewall firewall add rule name=$port dir=in action=allow protocol=TCP localport=$port”;
    }

    bash.exe -c “echo | sudo -S /etc/init.d/mysql restart”
    bash.exe -c “echo | sudo -S service apache2 restart”

    Reply
  11. Just noticed that parts of the text that I provided in my comment have disappeared when I submitted the comment???

    Reply
  12. Hello, I am having problems with Step 5. Please help me!
    I enter:
    sudo -i
    then i do:
    wget -nv https://download.owncloud.org/download/repositories/production/Ubuntu_18.04/
    Release.key -O Release.key

    After this, it says, “Release.key: No such file or directory”
    I continue to add the script. WHen I put:
    apt-key add – /etc/apt/sources.list.d/owncloud.list

    Nothing happens. Then I put:
    apt-get update

    And it says: “E: Malformed entry 1 in list file /etc/apt/sources.list.d/owncloud.list (Suite)
    E: The list of sources could not be read.”

    If I add the last line of code, it says the same thing. I don’t know what is wrong. I followed all the other steps exactly and everything went ok. Why isn’t it working?? And you say it’s possible to download the owncloud from the site directly, but you don’t say how. Would that be easier than using the code to install it since it’s not working for me? I tried to go on the Owncloud site and I downloaded the .deb file, but I can’t figure out how to install it. Ugh. this is really hard.

    Please help. Thank you

    Reply
    • The repository method is not applicable anymore, hence to get the latest release we have to manually download the Owncloud files. We have updated the tutorial please follow it again.

      Reply
  13. I’m stuck with MySQL – Ubuntu 20.04

    [email protected]:~$ sudo service apache2 restart
    * Restarting Apache httpd web server apache2 [ OK ]
    [email protected]:~$ sudo /etc/init.d/mysql stop
    * Stopping MySQL database server mysqld [ OK ]
    [email protected]:~$ sudo /etc/init.d/mysql start
    * Starting MySQL database server mysqld su: warning: cannot change directory to /nonexistent: No such file or directory
    [ OK ]
    [email protected]:~$ sudo mysql
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 10
    Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

    Copyright (c) 2000, 2022, Oracle and/or its affiliates.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

    mysql> CREATE DATABASE owncloud;
    Query OK, 1 row affected (0.02 sec)

    mysql> GRANT ALL ON owncloud.* to ‘h2smedia’@’localhost’ IDENTIFIED BY ‘A4rt+-9oid’;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IDENTIFIED BY ‘A4rt+-9oid” at line 1
    mysql>

    Best Regards!

    Reply
    • Use these steps:

      CREATE DATABASE owncloud;

      CREATE USER ‘h2smedia’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘my-strong-password-here’;

      GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON owncloud.* TO ‘h2smedia’@’localhost’;

      Reply

Leave a Comment

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