Skip to content

Instructions for making your computer into WSL2 developer environment with Laravel Projects in Windows OS

Notifications You must be signed in to change notification settings

mark123jesper/wsl2-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Prepare setup to install PHP

sudo add-apt-repository ppa:ondrej/php

Update packages available

sudo apt-get update && sudo apt-get upgrade

Install PHP 8

sudo apt-get install php8.0

Install PHP Extensions, curl, mysql and more useful tools needed

sudo apt-get install jq xsel libnss3-tools zip unzip nginx mysql-server redis-server php8.0-fpm php8.0-cli php8.0-mysql php8.0-sqlite3 php8.0-intl php8.0-zip php8.0-xml php8.0-curl php8.0-mbstring php8.0-redis php-pear php8.0-dev php8.0-gd -y

Installing Node Using the Node Version Manager

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bashrc
nvm install v14.15.1

MySQL Setup:

sudo usermod -d /var/lib/mysql/ mysql
sudo service mysql start
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
FLUSH PRIVILEGES;
exit
sudo service mysql restart

Laravel Setup
Composer:

cd ~
wget https://getcomposer.org/installer
php installer
sudo mv composer.phar /usr/local/bin/composer

Bash:

nano ~/.bash_aliases
  1. Put export PATH=~/.config/composer/vendor/bin:$PATH
  2. Save the file, and then `source ~/.bashrc

Using Valet

composer global require cpriego/valet-linux
valet install

Create Laravel app for testing

sudo chown -R your_user /opt/
cd /opt
composer create-project laravel/laravel example-app
cd example-app
valet link
sudo service nginx start
sudo service php8.0-fpm start
sudo service redis-server start
sudo service mysql start` // just making sure
  1. Add 127.0.0.1 example-app.test to your Windows HOST file
  2. Navigate to http://example-app.test to check

Using Sail, Docker and NGROK

  1. Install Docker
  2. Install Laravel Sail (Global or Locally per project it depends on you) globally
composer global require laravel/sail --dev

or locally

composer require laravel/sail --dev
  1. Navigate to your Laravel Project and install Sail Scaffold
php artisan sail:install
./vendor/bin/sail up
  1. Run the sail instance (make sure to enable integrations by setting it up in docker settings Settings>Resources>WSL Integration
  • Enable integration with my default WSL Distro (and enable your distro as well. In my case, it is Ubuntu)
./vendor/bin/sail up
  1. While the Container is running, use NGROK for local instance with certificate
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok
ngrok config add-authtoken <token>
ngrok http 80

About

Instructions for making your computer into WSL2 developer environment with Laravel Projects in Windows OS

Resources

Stars

Watchers

Forks

Releases

No releases published