### Set up OwnCloud server on Windows with WSL

I was following the instructions presented in Ref [1, 2] to set up the OwnCloud server on Windows with WSL. Specifically, steps [1-8] in Ref. [1] were followed exactly - the installation for WSL was, however, installed separately. Then concerning the SQL database setup, the 'MySQL' section in Ref. [2] was followed. Also, the installation of ownCloud server refers to the 'Download ownCloud' section in Ref. [2] as well. All steps beyond steps [1-8] in Ref. [1] and 'MySQL' and 'Download ownCloud' in Ref. [2] were skipped. To access the configuration of owncloud, refer to the section 'Configure ownCloud' in Ref. [2].

👉Ports configuration

Refer to the following links to gist for configuration files concerning the ports configuration,

/etc/apache2/ports.conf

/etc/apache2/sites-enabled/000-default.conf

👉Connection to WSL Apache server from outside (i.e., beyond localhost)

This link provide detailed explanation about the IP address assignment scheme for WSL 2 and we need to follow the instruction there to establish the connection from outside to WSL Apache server. Also, since each time when we launch the WSL, new IP address will be assigned to the virtual system and we have no way to make the IP address static. In this case, we can follow this link to grab the IP address of the virtual WSL system automatically and connect it to our Windows host. The following function can be put in powershell profile file so that we can do the configurations all-in-once,

Function own {
wsl sudo /etc/init.d/mysql start
wsl sudo service apache2 restart
$wsl_ip = (wsl hostname -I).trim() netsh interface portproxy add v4tov4 listenport=5051 listenaddress=0.0.0.0 connectport=5051 connectaddress=$wsl_ip
}

👉Port confliction & Firewall issues

Sometimes, if the connection cannot be established via public IP address (or domain name if configured), there could be multiple reasons. First, we may want to change the Apache configuration to let it listen to another alternative port, since sometimes other services (e.g., Jupyterlab) will take over the port used by Apache. Second, we want to make sure the rule for a specific port is added in Windows Firewall exception (inbound traffic).

👉Configure external drive

By default, onwCloud will use '/var/www/owncloud/data' as the data directory, where all files would be stored. Also, by default, using external local drive as storage is disabled (for safety reason). To enable this, we can refer to Ref. [3].

References

1. This comment has been removed by a blog administrator.