Skip to content

Instantly share code, notes, and snippets.

@erikhansen
Last active August 15, 2023 09:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save erikhansen/63c2d2fa88fa2102dc43c89ff1d980fa to your computer and use it in GitHub Desktop.
Save erikhansen/63c2d2fa88fa2102dc43c89ff1d980fa to your computer and use it in GitHub Desktop.
Running Warden on Windows with WSL 1 & 2

Running Warden on Windows with WSL 2

See this Github comment thread for any issues or additional context for getting Warden running on Windows with WSL 2.

The instructions below cover how to install Warden on Windows, using WSL 2.

  1. Install Ubuntu 20 LTS in WSL 2

    1. To access the shell/terminal inside of Ubuntu WSL, open the Ubuntu 20.04 program that will have been installed in the step above (If you want to be able to copy/paste, see here. Going forward, this article assumes you will run all commands inside of the Ubuntu terminal
  2. Install Docker Desktop (these instructions were tested using Docker 4.9.0 on June 13th, 2022)

  3. Install homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  4. Install Warden

    1. Try installing Warden using this command: brew install davidalger/warden/warden However if you run into an error like Error: The following formula cannot be installed from bottle and must be built from source. warden, then follow these steps:

      sudo mkdir /opt/warden
      sudo chown $(whoami) /opt/warden
      git clone https://github.com/davidalger/warden.git /opt/warden
      echo 'export PATH="/opt/warden/bin:$PATH"' >> ~/.bashrc
      PATH="/opt/warden/bin:$PATH"
      
    2. In order to avoid a warning about an invalid SSL certificate when loading Warden sites, you need to configure your browser to trust the certificate used by Warden. To do that in Firefox, go to Options > Privacy & Security > Certificates > View Certificates... and then import the certificate located at /c/.warden/ssl/rootca/certs/ca.cert.pem. Check all the boxes as you are importing the certificate.

  5. At this point you should now be able to use Warden to create new environments or initialize existing ones. You'll want to use a folder inside of the ~/ directory for your Warden sites, such as ~/sites.

  6. You will need to manually create hosts records for each site. Edit your hosts file and add an entry like this for each site you're managing with Warden:

    127.0.0.1 app.example.test
    

Additional notes

  1. You can access the files inside the Ubuntu installation using Window's File Explorer by typing in \\wsl$\<YourDistroName>\ to the address bar. You'll want to determine what the exact path is for your version of Linux and then create a bookmark to it for easy reference.
  2. If you don't already have one, you will want to create an SSH public/private key pair inside your Ubuntu installation. To do this, open the wsl program, run a command like cd ~, and then follow these instructions to setup an SSH key.
    1. See here for how to copy this SSH key into Warden
  3. Database connection: It's often helpful to use a MySQL GUI tool to connect to databases inside of Warden.
    1. MySQL Workbench: Here is a screenshot showing how you would configure Warden to connect to a project named 8020:
      screenshot
      • Note: you may need to run this command to copy the Warden tunnel SSH key to a location that is readable by MySQL Workbench:

         sudo cp /c/.warden/tunnel/ssh_key /c/warden_tunnel_ssh_key
        
    2. TablePlus: Here is a screenshot showing how you would configure Warden to connect to a project named 8020: screenshot
  4. You can use an IDE like PhpStorm to edit files inside of your Warden projects by opening up the project directory (e.g., /c/sites/example.test)

Running Warden on Windows with WSL 1

The instructions below cover how to install Warden on Windows, using WSL 1.

  1. Install Ubuntu 18 LTS in WSL

    1. To access the shell/terminal inside of Ubuntu WSL, open the wsl program that will have been installed in the step above (you can also run the Ubuntu 18.04 LTS program. If you want to be able to copy/paste, see here. Going forward, this article assumes you will run all commands inside of wsl
  2. Install Docker Desktop

  3. Follow the steps in this article. Some adjustments to the article:

    • Once you install Docker Desktop, go to Resources > File Sharing and select C
    • Before you move forward with the Verify Everything Works step, restart Windows
    • Skip this step: Can't use Docker for Windows?
    • Once you get to the You're all done! You can skip the 17.09 steps below if you followed the above steps. section of the article, move on to the next step below.
  4. Run sudo apt install linuxbrew-wrapper

    • You may see an error like this:

       Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH.
       /usr/bin/brew: 78: exec: /home/erikhansen/.linuxbrew/bin/brew: not found
      

      Ignore that error and run the commands listed here.

  5. Install Warden

    1. By default, Warden will want to use the home directory of your Linux installation. Due to the nature of how files are shared between Linux and Windows, we need to configure Warden to use the /c directory (that you should have setup as a shared directory in a previous step). Run the following commands inside a wsl shell:
      echo 'export WARDEN_HOME_DIR=/c/.warden' >> ~/.bashrc
      echo 'export WARDEN_COMPOSER_DIR=/c/.composer' >> ~/.bashrc
      export WARDEN_HOME_DIR=/c/.warden
      export WARDEN_COMPOSER_DIR=/c/.composer
      
    2. Increase the Docker Desktop memory limit, per the Warden documentation recommendation
    3. Install Warden using Homebrew
    4. In order to avoid a warning about an invalid SSL certificate when loading Warden sites, you need to configure your browser to trust the certificate used by Warden. To do that in Firefox, go to Options > Privacy & Security > Certificates > View Certificates... and then import the certificate located at /c/.warden/ssl/rootca/certs/ca.cert.pem. Check all the boxes as you are importing the certificate.
  6. At this point you should now be able to use Warden to create new environments or initialize existing ones. You'll want to use a folder inside of the /c directory for your Warden sites, such as /c/sites.

  7. You will need to manually create hosts records for each site. Edit your hosts file and add an entry like this for each site you're managing with Warden:

    127.0.0.1 app.example.test
    
@rafaelpatro
Copy link

Amazing! Save my day

@fidellakis-coolibar
Copy link

Just what I needed!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment