šŸ‘‹ Hello! I'm Dmitry
Full Stack Web-Developer
and Product Manager
Blog

Setting up šŸ‘·ā€ā™‚ļø Local Dev Server on Windows 10

Sunday, December 8, 2019
Setting up šŸ‘·ā€ā™‚ļø Local Dev Server on Windows 10

I've been using Homestead Vagrant Box for a long time and I'm very happy with it. It's a perfectly configured Virtual Machine built on top of Ubuntu that has everything to develop almost any web project.

In future I might switch to WSL which looks very promissing. Hopefully it would have improved performance and CentOs 8 support šŸ¤ž

Folder Structure

All my projects are located in one easy accessible directory ā€” c:\code. When working from Command Prompt you can type cd \code and get to desired project using TAB autocomplete feature.

Also I like to automate workflow and have helper scripts and functions available via Command Prompt. All of the scripts, batch files and portable software resides at c:\bin folder.

Apps needed

If you're starting from scratch and don't have Git, ConEmu, Clink, VS Code, VirtualBox, Vagrant, SourceTree ā€” go ahead and install all the latest releases.

ā€” When installing GIT make sure you check option:
"Use Git and optional Unix tools from the Command Prompt".
ā€” Having most development related executables under c:\bin directory can save you from using quotes in command prompt. Try installing above apps there.

Environment

To make Command Prompt more usefull you should modify Windows Environment Settings. Easy way to get to them is by pressing Win + S, typing env, and choosing ā€” "Edit Environment Variables for your account"

Add some directories to User's Variable ā€” "PATH" ā€” for easy access to executables that you'd collect there:
c:\bin ā€” here we'll be collecting our helper scripts
c:\bin\kitty ā€” for easy access to portable Kitty SSH client

Portable KiTTy SSH client

KiTTy is a most popular fork of a legendary PuTTy SSH client with many implemented enchancements. We'll be using portable version with my customized default settings which will have ā€” nice color scheme, default font set to Fira Code with Powerline symbols (add it to your fonts), default term set to xterm-256color, logging.

mkdir c:\bin\kitty\Sessions
mkdir c:\bin\kitty\Logs
curl -# -L -o c:\bin\kitty\kitty.exe http://www.9bis.net/kitty/files/kitty_nocompress.exe
curl -# -L -o c:\bin\kitty\Sessions\Default%20Settings https://gist.github.com/ossipov/880a930f79b8a01d981fdd4b6b8267a4/raw

ConEmu

ConEmu is the best Terminal for Windows and it comes with enormous ammount of settings that you can modify and tweak. You can launch it by pressing Win + S and start typing conemu. It also has a global shortcut configured to show and hide window on Ctrl + `.

Getting your dev stack

Depending on what you're building here are some links you might also find useful:
NodeJS, Yarn, PHP, Composer, Python, Go. Don't forget to add executables path to Windows PATH variable.

Homestead

By now you have VirtualBox and Vagrant installed. Open up ConEmu and start hacking šŸ˜Ž

rem -------------------------------------------------------
rem Add support for NFS
rem -------------------------------------------------------
vagrant plugin install vagrant-winnfsd

rem -------------------------------------------------------
rem Add Homestead Box to Vagrant 
rem -------------------------------------------------------
vagrant box add laravel/homestead

rem -------------------------------------------------------
rem Create keypair for Homestead
rem -------------------------------------------------------
mkdir %homepath%\.ssh\keys\homestead
ssh-keygen -N "" -f %homepath%\.ssh\keys\homestead\id_rsa

rem -------------------------------------------------------
rem Install Homestead
rem -------------------------------------------------------
mkdir c:\homestead
cd c:\homestead
git clone https://github.com/laravel/homestead.git .
git checkout release
init.bat
code -n c:\homestead\Homestead.yaml

Adjust Homestead.yaml config. Official docs are really good and easy to follow. If you created keypair with above command here is a correct location of those keys.

---
authorize: ~/.ssh/keys/homestead/id_rsa.pub
keys:
    - ~/.ssh/keys/homestead/id_rsa

folders:
    - map: c:\code\project.com
      to: /home/vagrant/project.com
      type: "nfs"
#    - map: c:\code\project2.com
#    to: /home/vagrant/project2.com
#     type: "nfs"

sites:
    - map: project.test
      to: /home/vagrant/code/project.com/public
#    - map: project2.test
#      to: /home/vagrant/code/project2.com/public

databases:
    - project1
#    - project2

features:
    - mariadb: true

After saving the file return to ConEmu and run

code -n %windir%\System32\drivers\etc\hosts

Edit Windows 10 hosts to make domains available for your browser

192.168.10.10     project.test
192.168.10.10     project2.test

ConEmu again

cd c:\homestead
vagrant up
cd \code\project.com
code .