Source: https://api.octoperf.com/doc/on-premise-infra/tutorials/wsl2-enterprise-deployment/

# Deploy On-Premise Infra on WSL2

![WSL2](https://api.octoperf.com/doc/on-premise-infra/tutorials/img/wsl2.jpeg)



This tutorial explains how to setup the entire OctoPerf On-Premise Infra platform using Windows Subsystem for Linux.

The Windows Subsystem for Linux (WSL) is a solution that allows running a Linux environment directly on Windows, using a terminal, with no third party Virtual Machine solution is required.

We're going to use its latest version, WSL2, which goes further beyond in terms of integration and simplicity.

## Prerequisites

This tutorial requires:

- A physical machine or server (NOT a virtual machine),
- Windows 10 or Windows Server 2019 (version 1709 or greater),
- Basic knowledge of Microsoft Windows,
- Basic knowledge of Linux,
- And basic knowledge of how [Docker](https://docker.com) works.

## Installing WSL2

First, we need to activate WSL2 on your Windows machine. Open a PowerShell terminal in Administrator mode: 

![Powershell1](https://api.octoperf.com/doc/on-premise-infra/tutorials/img/wsl2/Powershell1.jpg)

Enter the following command to enable WSL 1 :

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

![Powershell2](https://api.octoperf.com/doc/on-premise-infra/tutorials/img/wsl2/Powershell2.jpg)



Reboot your machine. Open PowerShell in admin mode again, and type the following command to enable WSL2:

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

![Powershell3](https://api.octoperf.com/doc/on-premise-infra/tutorials/img/wsl2/Powershell3.jpg)

Reboot your machine again.



You now have WSL2 installed on your machine.



## Installing Ubuntu

We are now ready to install Ubuntu on your Windows machine.

### If you have access to the Windows Store

Open the Microsoft Store to download and install Ubuntu:

![storeubuntu](https://api.octoperf.com/doc/on-premise-infra/tutorials/img/wsl2/storeubuntu.jpg)

Open a PowerShell terminal in admin mode, and set WSL2 as the default option:

```powershell
wsl --set-default-version 2
```

To check if your linux distribution is indeed using WSL2, type the following command:

```powershell
wsl --list --verbose
```

![Powershell4](https://api.octoperf.com/doc/on-premise-infra/tutorials/img/wsl2/Powershell4.jpg)

  

If it's not the case, enter this command to correct the configuration: 

```powershell
wsl --set-version Ubuntu 2
```



You now have Ubuntu on your Windows Server, it can be launched directly from the Windows Start Menu, like any other program.

### If you don't have access to the Windows Store

You might not have access to the Internet on your machine, for instance if you're using installing WSL2 on a Windows Server located in a private network.

First, you will need to download the distribution on a machine that has access to the internet, and transfert the "appx" file to your server.

The distributions are available on this page : 

[https://docs.microsoft.com/fr-fr/windows/wsl/install-manual](https://docs.microsoft.com/fr-fr/windows/wsl/install-manual)



Extract the appx file using Powershell, let's say it is named Ubuntu2004.appx :

```powershell
Rename-Item .\Ubuntu2004.appx .\Ubuntu2004.zip 
Expand-Archive .\Ubuntu2004.zip .\Ubuntu
```



Execute the .exe file extracted in the target directory to install the distribution



```powershell
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User") [System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu2004", "User")
```



You can now launch your distribution by typing "Ubuntu2004.exe" from any path.



## Installing Docker-CE on Ubuntu

After launching Ubuntu, see documentation explaining [how to install docker-ce on Ubuntu](https://docs.docker.com/engine/install/ubuntu/).



You can now start docker, with the following command:

```bash
sudo service docker start
```

You can access your local Windows drives directly from Ubuntu, by accessing the following directory: 

```bash
cd /mnt/
```

!!! warning
    If the docker service fails to start, you might want to try [the following command](https://patrickwu.space/2021/03/09/wsl-solution-to-native-docker-daemon-not-starting/):
	`update-alternatives --config iptables`
	And select the legacy option (usually 1). Now the docker service should start without any issue.
	

## Install the On-Premise Infra

The next steps are similar to a classic On-Premise Infra install on Unix, so please refer to our documentation on the subject:

- [How to setup the Enterprise Edition server](https://api.octoperf.com/doc/on-premise-infra/)
- [How to setup a Load Agent](https://api.octoperf.com/doc/on-premise-agent/provider-type/on-premise/#linux)
