Skip to content

Instantly share code, notes, and snippets.

@PolCPP
Forked from valeryan/WindowsSetup.md
Last active November 12, 2018 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PolCPP/52c4240e1fff4e8666ed988cc053ec51 to your computer and use it in GitHub Desktop.
Save PolCPP/52c4240e1fff4e8666ed988cc053ec51 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 Hyper and setup to use bash for windows (optional).
  3. Install Acrylic DNS Proxy.
  4. Download WSL Startup Scripts.

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
  6. Run sudo apt-get install network-manager libnss3-tools jq xsel build-essential libssl-dev dnsmasq nginx mysql-server php-fpm php-cli php-mysql php-sqlite3 php-intl php-zip php-xml php-curl php-mbstring redis-server php-redis
  7. Run sudo usermod -d /var/lib/mysql/ mysql
  8. Run $ sudo mysql -u root mysql> USE mysql mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> exit; $ mysql -u root mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('root'); mysql> exit;

Node (NVM)

  1. Make sure you have pip installed.
  2. Run sudo pip install nodeenv

Composer

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

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. 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.

Optional Extras

If the web server seems to run slow

  1. Add fastcgi_buffering off; to the nginx fcgi conf.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment