Skip to content

Instantly share code, notes, and snippets.

@brettsmason
Forked from valeryan/WindowsSetup.md
Last active November 24, 2019 13:22
Show Gist options
  • Save brettsmason/a3cdda299354784b96d8e102594097e1 to your computer and use it in GitHub Desktop.
Save brettsmason/a3cdda299354784b96d8e102594097e1 to your computer and use it in GitHub Desktop.
Local WSL Setup

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 with an Ubuntu 16 installed as WSL.

Windows Setup Prerequisites

  1. Install WSL.
  2. Install Terminus and setup to use bash for windows (optional).
  3. Install Acrylic DNS Proxy.
  4. Download WSL Startup Scripts.
  5. Install Xming (optional).

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 apt-get install software-properties-common
  5. Run sudo add-apt-repository ppa:ondrej/php.
  6. Run sudo apt-get update && sudo apt-get upgrade
  7. Run sudo apt-get install network-manager libnss3-tools jq xsel build-essential libssl-dev zip unzip dnsmasq nginx mariadb-server php-fpm php-cli php-mysql php-sqlite3 php-intl php-zip php-xml php-curl php-mbstring redis-server php-redis php-pear php-dev pkg-config libz-dev libzip-dev libmemcached-dev libmemcached11 libmemcachedutil2 libmagickwand-dev imagemagick memcached

MySql

I ran into some issues with MySql not having a password and not being able to get mysql_secure_installation to work. As a workaround I used mysqladmin. 3. Run sudo service mysql start 2. Run sudo mysql_secure_installation 3.

$ sudo mysql -u root # I had to use "sudo" since is new installation

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ sudo service mysql restart

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mariadb-php-lamp-stack-debian9

Edit Nginx config

  1. nano /etc/nginx/nginx.conf
  2. Add fastcgi_buffering off; and fastcgi_keep_conn on;

Node

  1. Run curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh.
  2. Run sudo bash nodesource_setup.sh.
  3. Run sudo apt-get install nodejs.

Yarn

  1. Run curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -.
  2. Run echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list.
  3. Run sudo apt-get update && sudo apt-get install yarn.

Composer

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

WP CLI

  1. Run curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  2. Run php wp-cli.phar --info to check its working
  3. Run chmod +x wp-cli.phar
  4. Run sudo mv wp-cli.phar /usr/local/bin/wp

Valet WSL

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

Bash Config

  1. Run vi ~/.bash_aliases.
  2. Add export PATH=~/.composer/vendor/bin:$PATH.
  3. Also if you want to use Gui application via Xming add export DISPLAY=:0.0. (optional)
  4. 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 *.dev to bottom of 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. Run valet domain dev. (optional: defaults to .test and my preference is .dev)
  3. Browse to a laravel project folder and run valet link.
  4. To test, browse to folder.dev.
  5. In WSL and in 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. Refersh your browser and see if HTTPS in enabled and valid. You may need to restart valet and your browser to get everything in sink.

WSL Startup (Windows)

  1. Move the WSL startup scripts you downloaded earlier to C:/tools/wsl-startup/.
  2. Make any adjustments to services.sh.
  3. Create a Task Scheudule to run bash-start.vbs at logon.
  4. Reboot to test startup. You should be able to browse to any valet configured sites after reboot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment