Skip to content
Muhammad Nur'Ihsan Bin Berahim edited this page Jun 17, 2020 · 14 revisions

Windows Development Environment Setup

This document outlines the steps I take to setup my environment on windows using WSL. This requires being on the windows 10 Creative update or greater. It is written for the Ubuntu version of WSL.

WSL 2 Support

WSL 2 is not currently supported. It will technically work but several issues may require additional steps. See Discussion of Known issues with WSL2 for more information.

Windows Setup Prerequisites

  1. Install WSL.
  2. Install Terminus and set up to use bash for windows (optional).
  3. Install Acrylic DNS Proxy.

WSL Setup

  1. Open a bash instance in a terminal.
  2. Run sudo visudo.
  3. Add ALL ALL = (root) NOPASSWD: /usr/sbin/service and username ALL=(ALL) NOPASSWD: ALL to sudoer config.
  4. Run sudo add-apt-repository ppa:ondrej/php.
  5. Run sudo apt-get update && sudo apt-get upgrade

Build Tools & Dependencies

  1. Run sudo apt-get install libnss3-tools jq xsel libssl-dev zip unzip pkg-config libmemcached11 libmemcachedutil2 imagemagick memcached redis-server

Networking

  1. Run sudo apt-get install network-manager dnsmasq

LEMP Stack

  1. Run sudo apt-get install nginx mysql-server php-fpm php-cli php-mysql php-sqlite3 php-intl php-zip php-xml php-curl php-mbstring php-redis php-pear php-dev

MySql Password

In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the auth_socket plugin by default rather than with a password. In order to use a password to connect to MySQL as root, you will need to switch its authentication method from auth_socket to mysql_native_password. To do this, open up the MySQL prompt from your terminal:

  1. Run sudo usermod -d /var/lib/mysql/ mysql
  2. Run sudo service mysql start
  3. Run sudo mysql
  4. Run ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; in mysql. Be sure to change password to a strong password of your choosing.
  5. Run FLUSH PRIVILEGES; in mysql.
  6. Run exit
  7. Run sudo service mysql restart
  8. To test logging in as a normal user run mysql -u root -p and enter the password from step 4.

Reference

Node

  1. Run curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -.
  2. Run sudo apt-get install nodejs.

Composer

  1. Run wget https://getcomposer.org/installer.
  2. Run php installer.
  3. Run sudo mv composer.phar /usr/local/bin/composer.

Valet WSL

  1. Run composer global require valeryan/valet-wsl.

Bash Config

  1. Run vi ~/.bash_aliases.
  2. Add export PATH=~/.config/composer/vendor/bin:$PATH.
  3. Run source ~/.bashrc.

Acrylic Setup (Windows)

  1. In Windows hit the windows key and search for Acrylic and find Edit Acrylic Host File.
  2. Add 127.0.0.1 *.test to the bottom of the file and save.
  3. Hit the windows key again and search for Stop Acrylic Service.
  4. Search again for Start Acrylic Service.

Valet Setup (WSL)

  1. Run valet install.
  2. Browse to a Laravel project folder and run valet link.
  3. To test, browse to folder.test.
  4. In WSL and in the project folder run valet secure.

Valet Setup (Windows)

  1. In Windows Explorer browse to C:/tools/valet/certs/ and double click the install_certs.cmd file. This will install any certs in the folder as trusted root certificates.
  2. Refresh your browser and see if HTTPS is enabled and valid. You may need to restart valet and your browser to get everything in sync.

WSL Startup (Windows)

  1. Follow my WSL Startup Gist

Setup Cron For Projects

1 Run sudo crontab -e.

Crontab Setup Example

*/5 * * * * php /mnt/c/username/Projects/folder/artisan schedule:run >> /dev/null 2>&1