Setting up a development environment on Windows can be a challenging task, but with the right tools and guidance, it can be made easier. This guide will provide step-by-step instructions for setting up a development environment on Windows, including installing WSL, Terminal, Git, and Visual Studio Code Insider.
Before beginning the setup process, ensure that your system meets the following requirements:
- Windows 10 version 1903 or higher
- Administrator access to your machine
- An internet connection
To set up your Windows development environment, the first and most vital step is installing the Windows Subsystem for Linux (WSL). π
WSL 2 is the latest version, featuring a full Linux kernel and complete system call compatibility. No longer requiring multiple steps, all you need to do is execute this single command in PowerShell or Command Prompt:
wsl --install
This command accomplishes the following:
- Enables the optional WSL and Virtual Machine Platform components
- Downloads and installs the latest Linux kernel
- Sets WSL 2 as the default
- Downloads and installs the Ubuntu Linux distribution (a reboot may be required)
Should you wish to change your default Linux distribution, follow the provided documentation. π
With WSL at your disposal, the Windows development landscape becomes yours to conquer! πͺπ
Installing WSL through the store will allow you to get the latest WSL updates and features faster, and without needing to modify your Windows version.
π After installing your Linux distribution with WSL, launch it from the Start menu. You'll create a unique User Name and Password during the initial run.
π‘ These credentials are specific to each Linux distribution and don't relate to your Windows user.
π€ Your account becomes the default user and auto-signs in on launch.
π Each WSL distribution has its own set of user accounts. Configuring a new account is necessary when adding, reinstalling, or resetting.
Tip
You can configure WSL to not require a password for sudo.
Replace MY_USERNAME
below with your actual username:
sudo nano /etc/sudoers.d/MY_USERNAME
Add the following line:
MY_USERNAME ALL=(ALL) NOPASSWD:ALL
To keep your system shipshape, regularly update and upgrade packages with your distribution's preferred package manager. For Ubuntu or Debian, execute:
sudo apt update && sudo apt upgrade
βοΈ Windows won't auto-update or upgrade your Linux distribution(s). Linux users typically prefer controlling this task themselves.
If WSL stops working, you can restart it with these two commands from PowerShell/Command Prompt:
wsl.exe --shutdown
wsl.exe
To build and manage your PHP projects efficiently, you'll need to install PHP and Composer on your WSL environment.
-
Install PHP:
# Install the php latest stable sudo apt install php -y # Check if success with php -v
π Now, you have PHP installed! Verify the installation with:
# Check if success with php -v
Composer is a dependency manager for PHP, which makes managing your project dependencies a breeze. You can also follow this link for actual installation.
-
Command-line installation:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
-
Move Composer to a global location:
sudo mv composer.phar /usr/local/bin/composer
π Composer is now installed! Verify the installation with:
composer --version
Tip
You do not need to install PHP or Composer locally. You can use Docker as an example:
docker run -it --rm --name my-running-script \
-v "$PWD":/usr/src/myapp \
-w /usr/src/myapp \
php:8.2-cli php your-script.php
docker run --rm php:8.2-cli sh -c 'php -r "echo \"Hello, World!\n\";"'
docker run --rm --interactive --tty \
--volume $PWD:/app \
composer <command>
By following these steps, you've equipped your WSL environment with PHP and Composer, ready for robust PHP development. Happy coding! π₯οΈβ¨
From your Linux terminal, use these commands to download and install popular Linux applications. Remember, if your distribution isn't Ubuntu, the package manager may vary from apt. Once installed, access the app through the Start menu under your distribution name. For instance, Ubuntu -> Microsoft Edge.
For more info check Linux GUI Apps.
Gnome Text Editor, the default text editor of the GNOME desktop environment, can be installed with a simple command:
sudo apt install gnome-text-editor -y
# To launch your bashrc file in the editor, enter:
gnome-text-editor ~/.bashrc
π Note: GNOME Text Editor takes over as GNOME/Ubuntu's default text editor in Ubuntu 22.10, replacing gedit. If you're using an older version of Ubuntu and prefer gedit, the previous default text editor, use this command:
GIMP, the free and open-source raster graphics editor, empowers you with image manipulation, free-form drawing, transcoding between various image formats, and more. To install GIMP, execute:
sudo apt install gimp -y
# To launch GIMP, simply type:
gimp
Nautilus, also known as GNOME Files, serves as the file manager for the GNOME desktop environment (akin to Windows File Explorer). To install Nautilus, use:
sudo apt install nautilus -y
# Launch Nautilus by entering:
nautilus
VLC, the free and open-source multimedia player and framework, handles most multimedia files with ease. To get VLC, run:
sudo apt install vlc -y
# Launch VLC by typing:
vlc
The Linux windowing system, X11, comes with a collection of miscellaneous apps and tools like xclock, xcalc calculator, xclipboard for cut and paste, xev for event testing, and more. For installation:
sudo apt install x11-apps -y
# To launch a specific tool, simply enter its name, for example:
xcalc
xclock
xeyes
The VS Code Remote - SSH extension lets you open a remote folder on any machine with a running SSH server and use all of VS Code's features. After connecting to a server, you can work with files and folders anywhere on the remote filesystem.
To get started, you need to install an OpenSSH compatible SSH client if one is not already present.
To install OpenSSH using PowerShell, run PowerShell as an Administrator. To make sure that OpenSSH is available, run the following cmdlet:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Then, install the server or client components as needed:
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
To start and configure OpenSSH Server for initial use, open an elevated PowerShell prompt (right click, Run as an administrator), then run the following commands to start the sshd service
:
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
Discover the power of π Git version control system on WSL! π
Git often comes pre-installed with most Windows Subsystem for Linux distributions. However, to ensure you have the latest version, consider updating it. Don't forget to set up your git config file.
π₯ To install Git, visit the Git Download for Linux site. Each Linux distribution has its unique package manager and install command.
π For the latest stable Git version on Ubuntu/Debian, run:
sudo apt-get install git
π Note: If you haven't already, you may want to install Git for Windows too. π
To set up your Git config file, open a WSL command line and set your name with this command (replacing "Your Name" with your preferred username):
git config --global user.name "Your Name"
Set your email with this command (replacing "[email protected]" with the email you prefer):
git config --global user.email "[email protected]"
Finally, add your GitHub username to link it to git (case sensitive!):
git config --global user.username "GitHub username"
β οΈ You can double-check any of your settings by typinggit config --list
. To make any changes, just type the necessary command again as in the examples above.
To seamlessly share credentials and settings between WSL and the Windows host, it's best to install the latest Git for Windows. The installation includes Git Credential Manager (GCM), with each new release containing the latest version. During installation, GCM is set as the default credential helper.
To set up GCM for use with a WSL distribution, open your distribution and enter this command:
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
Local Git configuration allows us to sign commits using a GPG key. Once signed, GitHub marks those commits as verified, giving others confidence that the changes originate from a trusted source.
To get started, we need to install Gpg4Win. π₯
If you installed gnupg using Winget or Chocolatey from the command line, remember to restart the console or refresh the environment variables.
π₯οΈ Open a Windows PowerShell command window.
Run this command to generate the GPG key:
gpg --full-generate-key
It will prompt for specific details, use the following:
- Kind: RSA & RSA.
- Key Size: 4096 bits.
- Expiration: 0 (Never expires).
- Real Name: Use your GitHub Username.
- Email: Use your GitHub email; this will be the alias of the GPG key.
- Comment: You can leave this empty.
π₯οΈ Open a Windows PowerShell command window.
# 1.First locate where gnupg is installed and save it into a variable:
$gnupgPath = where.exe gpg
# 2.Configure Git to use gnupg as GPG program:
git config --global gpg.program $gnupgPath
# 3.Configure Git to sign all commits by default:
git config --global commit.gpgsign true
# 4.Configure Git to use your GPG key as signing key
git config --global user.signingkey "Use the alias of the GPG key here"
# 5.Optional: Configure Git to sign all tags by default:
git config --global tag.gpgsign true
π₯οΈ Open a Windows PowerShell command window.
# 1.First locate where gnupg is installed and save it into a variable:
$gnupgPath = where.exe gpg
# 2.Translate the path to WSL:
$gnupgWslPath = wsl wslpath $gnupgPath
# 3.Configure Git to use gnupg as GPG program:
wsl git config --global gpg.program $gnupgWslPath
# 4.Configure Git to sign all commits by default:
wsl git config --global commit.gpgsign true
# 5.Configure Git to use your GPG key as signing key
wsl git config --global user.signingkey "Use the alias of the GPG key here"
# 6.Optional: Configure Git to sign all tags by default:
wsl git config --global tag.gpgsign true
- Export the Key
To export the GPG key, use the following command:
gpg --armor --export "Use the alias of the GPG key here"
- Add GPG Key on GitHub
Now, open the GitHub page to add the GPG key:
π GitHub Add GPG Key
Windows Terminal unleashes the potential of any application with a command line interface.
π§ Whenever a new WSL Linux distribution is installed, Windows Terminal conjures a dedicated instance that you can fine-tune to your liking.
π‘Head to the Windows Terminal docs for setup and personalization assistance. Customize:
-
Installation: Get it from the Microsoft Store - Windows Terminal or Windows Terminal (Preview).
-
Custom Actions: Set up keyboard shortcuts that suit your natural workflow.
-
Default Startup Profile: Configure your preferred starting setup.
- Select the
Λ
icon from Windows Terminal and go to the Settings menu - Startup section find the Default profile dropdown, select Ubuntu and Windows Terminal as the Default terminal
- Select the
-
Starting Directory
- Under the Profiles section in the settings menu click on Ubuntu
- At the General tab, you will find a Starting directory input
- Enter the following replacing "username" with your Ubuntu user name:
\\wsl$\Ubuntu\home\username
- You can leave the
Use parent process directory
box unchecked - If it is still opening into your
/
directory, change theCommand line
setting located right above theStarting directory
input box to the following:wsl.exe -d Ubuntu
-
Appearance: Tailor themes, color schemes, names, starting directories, background images, and more...
-
Set up a custom prompt for PowerShell or WSL with Oh My Posh.
Z shell, also known as Zsh, works almost identically to the standard BASH shell found on default Linux installs. But what makes it stand out are its incredible support for plugins and themes, along with cool features like spelling correction and recursive path expansion. It's time to leave BASH behind and unlock the full potential of Zsh! πͺπ
To install Zsh, execute this command:
sudo apt install zsh
Once installed, type zsh
in the terminal. Zsh will prompt you to choose some configurations. Don't worry; we'll handle this later while installing oh-my-zsh. For now, select option 0
to create the config file and prevent this message from showing again. π οΈπ 0οΈβ£
The most popular plugin framework by far is OhMyZsh. It comes preloaded with a plethora of plugins, themes, helpers, and more. Not only does it enhance productivity, but it also adds a touch of coolness to your terminal. πππ»
Before we proceed, ensure you have cURL installed. It's a fantastic way to transfer data from the command line, and that's how we'll download OhMyZsh.
sudo apt install curl
Enter the following command into your terminal to install OhMyZsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Great! Now you should see a .oh-my-zsh
directory inside your home directory. To customize plugins and themes, edit your .zshrc
file, also found in your home directory.
Here is a list of all the themes and plugins bundled with OhMyZsh. πΌπ¨π
While there are countless plugins available, here are two highly recommended ones:
π zsh-autosuggestions
This plugin provides autosuggestions for zsh, suggesting commands as you type based on history and completions.
- Clone this repository into
$ZSH_CUSTOM/plugins
(by default~/.oh-my-zsh/custom/plugins
):
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- Add the plugin to the list of plugins for Oh My Zsh to load (inside
~/.zshrc
):
plugins=(git zsh-autosuggestions)
- Start a new terminal session. πποΈ
This package provides syntax highlighting for the zsh shell, highlighting commands as they are typed in an interactive terminal. It helps in reviewing commands before running them, particularly in catching syntax errors.
- Clone this repository into oh-my-zsh's plugins directory:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- Activate the plugin in
~/.zshrc
:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
- Start a new terminal session. ππ
For a vast list of plugins, check out the awesome zsh plugins repository. π οΈππ
Oh My Posh is a delightful framework that enhances your Linux terminal prompt and makes it not only more informative but also visually appealing. Customize and transform your prompt into something that matches your style and productivity needs. ππ
- Install
# Using Homebrew
brew install jandedobbeleer/oh-my-posh/oh-my-posh
# Manual
curl -s https://ohmyposh.dev/install.sh | bash -s
- Activate the plugin in
~/.zshrc
:
# Oh My Posh init Theme
eval "$(oh-my-posh init zsh --config $(brew --prefix oh-my-posh)/themes/jandedobbeleer.omp.json)"
- Start a new terminal session. ππ
Next, you'll need to install and set up a suitable font to display the special characters used by Oh My Posh.
That's it! Your Linux terminal prompt should now be enhanced with the beautiful and informative Oh My Posh theme. Customize further by exploring the various options available in the theme settings. β¨π¨
For more information and advanced customization, check out the official Oh My Posh documentation and unleash the full potential of your Linux terminal prompt! π»π₯
Homebrew is a popular package manager for macOS, and now it's available for Linux too! With Homebrew, you can easily install, update, and manage various packages and applications on your Linux system.
To install Homebrew on Linux, follow these steps:
-
Open a terminal window.
-
Install Homebrew using the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
That's it! Enjoy using Homebrew to simplify package management on your Linux system. πΊπ
Microsoft PowerToys is a set of handy utilities for Windows, boosting productivity and improving multitasking. It includes features like window management, keyboard shortcuts, color picker, image resizer, and more.
You can install Microsoft PowerToys using multiple methods:
- Winget: Open a terminal and run:
winget install Microsoft.PowerToys --source winget
-
Microsoft Store: Search for "Microsoft PowerToys" in the Microsoft Store and install it from there.
-
GitHub: Visit the official PowerToys GitHub page, download the latest release installer, and follow the installation wizard.
Access PowerToys Settings from the Start menu or system tray to enable, disable, and customize utilities.
-
FancyZones: Organize windows into custom layouts for better multitasking.
-
Shortcut Guide: Display helpful keyboard shortcuts overlay.
-
PowerRename: Batch rename files with advanced search and replace.
-
Color Picker: Easily pick colors from your screen.
-
Image Resizer: Resize images from File Explorer.
-
File Explorer Preview Pane: Preview files directly in File Explorer.
π Recommended Visual Studio Code Insiders for seamless remote development and debugging with WSL.
π Use Visual Studio Code Insiders:
Follow these steps to get started:
- Install Visual Studio Code insiders.
- Get the Remote Development extension pack for WSL.
- Follow this step-by-step guide to Get started using Visual Studio Code with WSL.
Once set up, open your WSL project with a VS Code remote server:
code-insiders .
Don't forget the period at the end to open the current directory. π«π‘
π‘ Note:
When using Remote - WSL, you must install any VS Code extensions you need separately. Extensions that are already installed locally on VS Code won't be automatically available in the WSL environment. To Learn more, refer to the documentation.
The WSL2 shell can be chosen as the default VS Code terminal by pressing Ctrl
+ Shift
+ P
and typing/choosing Terminal: Select Default Profile, then selecting zsh:
The tutorials below will walk you through running Visual Studio Code with the Remote Development extensions.
Tutorial | Description |
---|---|
π» Remote via SSH | Connect to remote and virtual machines with Visual Studio Code via SSH. |
π§ Work in WSL | Run Visual Studio Code in Windows Subsystem for Linux. |
π³ Develop in Containers | Run Visual Studio Code in a Docker Container. |
π GitHub Codespaces | Connect to a codespace with Visual Studio Code. |
Docker enables you to set up remote development containers effortlessly. Follow this step-by-step guide to get started with Docker remote containers on WSL 2 and connect your project to a remote development container using Docker Desktop for Windows.
-
Install Docker Desktop for Windows: Download and install Docker Desktop from the official Docker website.
-
Configure Docker for WSL 2: Open Docker Desktop settings and enable the "Use the WSL 2 based engine" option under the "General" section.
-
Connect to WSL 2: Open a terminal in your Linux distribution running on WSL 2 and ensure you can run Docker commands without any issues.
# Display the version and build number by entering:
docker --version
# Test that your installation works correctly by running a simple built-in Docker image using:
docker run hello-world
With Docker Desktop for Windows, you can conveniently manage and switch between different remote development containers directly from the Docker interface.
Now you're all set to enjoy the power of remote development with Docker containers! Happy coding! ππ»
Develop apps using Docker with ease and efficiency using VS Code and essential extensions: WSL, Dev Containers, and Docker. π©βπ»π³
-
Install VS Code WSL Extension: Seamlessly open Linux projects running on WSL in VS Code, eliminating pathing issues and cross-OS challenges.
-
Install VS Code Dev Containers Extension: Work inside a container for your project folder or repository, utilizing VS Code's full power.
-
Install VS Code Docker Extension: Manage containerized applications directly from VS Code. Pair with Dev Containers for a smooth development environment. ποΈ
Consider these essential tips:
-
Consistent Line Endings: When working with the same repository locally in Windows and inside a container, ensure consistent line endings for smooth collaboration. Check out our tips and tricks for details.
Adding the following to .gitattributes file to the root of your repository:
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
- Seamless Git Credentials: If you clone using a Git credential manager, your container will have access to your credentials automatically! For SSH keys, you can also opt-in to sharing them. Find more about Sharing Git credentials with your container.
If you want to GPG sign your commits, you can share your local keys with your container as well. You can find out about signing using a GPG key in GitHub's documentation.
If you do not have GPG set up, you can configure it for your platform:
- On WSL:
- Install Gpg4win on the Windows side.
- Install
gpg
in your WSL distro.sudo apt install gpg
- Register a
pinentry
GUI in your WSL distro.echo pinentry-program /mnt/c/Program\ Files\ \(x86\)/Gpg4win/bin/pinentry.exe > ~/.gnupg/gpg-agent.conf
- Reload the gpg agent in WSL.
gpg-connect-agent reloadagent /bye
π Note: For Windows user, the gpg signing key must be configured using the Windows GUI or CLI (powershell/cmd) and not in Git Bash. A Dev Container can't access the gpg keys set in Git Bash even though it is in your ~/.gnupg/ folder, accessible in the Windows Explorer.
Next, install gnupg2 in your container by updating your Dockerfile
.
RUN apt-get update && apt-get install gnupg2 -y
Or if running as a non-root user:
RUN sudo apt-get update && sudo apt-get install gnupg2 -y
Make sure you have Docker Desktop installed and properly configured on your Windows machine to follow this guide successfully. Remote development containers provide a convenient and consistent development environment across different machines and platforms, enhancing productivity and collaboration.
- Postman - A collaboration platform for API development with features like automated testing, mock servers, and documentation generation.
- HeidiSQL - "Heidi" lets you see and edit data and structures from computers running one of the database systems MariaDB, MySQL, Microsoft SQL, PostgreSQL and SQLite.
- FileZilla - A fast and reliable FTP, FTPS, and SFTP client for file transfer.
- PuTTY - A free and open-source terminal emulator, serial console, and network file transfer application.
- MySQL Workbench - A visual database design tool that integrates SQL development, administration, database design, creation, and maintenance into a single, seamless environment.
- WizTree - A disk space analyzer for quickly scanning your entire hard drive and then shows you which files and folders are using the most disk space.
- Notion - A note-taking and collaboration application with markdown support.
- WinMerge - A free and open-source differencing and merging tool for Windows.
- DBngin - All-in-One Database Version Management Tool - The easiest way to get started with PostgreSQL, MySQL, Redis & more
- Laravel Herd - Laravel development perfected - One click PHP development environment. Zero dependencies. Zero headaches.
- ....