Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WSL Development Environment

WSL Development Environment



  1. Elevated PowerShell: wsl --install
  2. Reboot computer when prompted.
  3. Setup will continue automatically and install Ubuntu.
  4. Setup a user and password for Ubuntu when prompted.
  5. Install Microsoft Terminal, configure fonts and theme.
  6. Install Visual Studio Code, configure settings, keybinds, theme, and extensions.



sudo apt update
sudo apt upgrade

Install Zsh and Oh My Zsh


sudo apt install zsh
sh -c "$(curl -fsSL"

Install some utilities

sudo apt install xdg-utils unixodbc-dev zip unzip software-properties-common

Install PHP

sudo apt install php php-dev php-pear php-curl php-bcmath php-mbstring php-gd php-xml php-zip php-intl php-sqlite3 php-mysql php-redis php-ldap

Install multiple versions of PHP (Optional)

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade

The below script will install PHP 8.1, repeat for all the versions you wish to install.

sudo apt install php8.1 php8.1-dev php8.1-curl php8.1-bcmath php8.1-dom php8.1-mbstring php8.1-gd php8.1-xml php8.1-zip php8.1-intl php8.1-sqlite3 php8.1-mysql php8.1-redis php8.1-ldap

You can check your active PHP version with php -v.

To change PHP version:

sudo update-alternatives --config php

Install Composer


Get latest script from above if following is outdated.

php -r "copy('', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

sudo mv composer.phar /usr/local/bin/composer

sudo composer self-update
composer -V

Install NPM


curl -fsSL | sudo -E bash -
sudo apt update
sudo apt install nodejs
node -v
npm -v

Install Yarn


curl -sS | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
yarn -v

Install Image Manipulation Utilities (Optional)


sudo apt install jpegoptim optipng pngquant gifsicle
sudo npm install -g svgo

Install Puppeteer (Optional)


curl -sL | sudo -E bash -
sudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev libxshmfence-dev
sudo npm install --global --unsafe-perm puppeteer
sudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium

Install SQLite

sudo apt install sqlite3

Install MySQL

sudo apt install mysql-server
sudo usermod -d /var/lib/mysql mysql
sudo service mysql start
sudo mysql -u root -p

Hit enter at password prompt with blank password.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secret';
sudo mysql_secure_installation
  • Validate Password Component? No
  • Change root password? No
  • Remove anonymous users? Yes
  • Disallow root login remotely? Yes
  • Remove test database and access to it? Yes
  • Reload privilege tables now? Yes

Install SQLSRV Drivers (Optional)


Change PHP version from 8.0 to whatever you have installed (php -v) in following script.

sudo su
curl | sudo apt-key add -
curl > /etc/apt/sources.list.d/mssql-release.list
apt update
apt install msodbcsql17
pecl install sqlsrv
pecl install pdo_sqlsrv
printf "; priority=20\\n" > /etc/php/8.1/mods-available/sqlsrv.ini
printf "; priority=30\\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini
phpenmod -v 8.1 sqlsrv pdo_sqlsrv
php -m | grep sql

Exit root prompt (ctrl+d).

Install Redis

sudo apt install redis-server
sudo service redis-server start

Install Keychain and SSH Keys

sudo apt install keychain

Make sure to add id_rsa and files to ~/.ssh/

sudo chmod -R a-rwx ~/.ssh
sudo chmod -R u+rwX ~/.ssh

Update .zshrc

vi .zshrc

Add Composer bin path to $PATH variable. Edit the second line in the .zshrc file:

export PATH=$HOME/bin:/usr/local/bin:$HOME/.config/composer/vendor/bin:$PATH

Add keychain to end of .zshrc file:

# Keychain
/usr/bin/keychain --quiet $HOME/.ssh/id_rsa
source $HOME/.keychain/$HOSTNAME-sh

Note: if $HOSTNAME is not set, manually type the hostname-sh found in ~/.keychain/ that ends with "-sh":


# Keychain
/usr/bin/keychain --quiet $HOME/.ssh/id_rsa
source $HOME/.keychain/ryan-gaming-sh

Install global Composer packages

composer global require laravel/installer
composer global require beyondcode/expose


Add .aliases file to home and source in .zshrc config


# Aliases
source $HOME/.aliases

The Silver Searcher

sudo apt install silversearcher-ag


git config --global "John Doe"
git config --global



After every reboot, you'll have to manually start up MySQL and Redis services.

sudo service mysql start
sudo service redis-server start

Web Server

I use Laravel primarily so I use php artisan serve as a web server. In cases where I'm not using Laravel I use php -S

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