• 1 Update your Ubuntu system first

    Warning!  Upgrade Ubuntu system usually takes no longer than 30 mins.  Make sure you don't interrupt once the upgrade is running or else you risk ruining the WSL and will have to reinstall it with IT's help.

    sudo apt-get update 
    sudo apt-get dist-upgrade

     

    • How to check current version of Ubuntu
      lsb_release -a

 

  • 2 Install PHP7.3 

     

    • Add ondrej/php which has PHP 7.3 package and other required PHP extensions.

      sudo add-apt-repository ppa:ondrej/php
      sudo apt-get update
    • Install PHP 7.3

      sudo apt-get install php7.3
      • Check php version

        php -v
    • Installing PHP 7.3 Extensions

      sudo apt-get install php7.3-cli php7.3-json php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json

 

  • 3 Install composer globally

    • Install composer (https://getcomposer.org/download/)

      To quickly install Composer in the current directory, run the following script in your terminal. To automate the installation, use the guide on installing Composer programmatically.

      php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
      php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
      php composer-setup.php
      php -r "unlink('composer-setup.php');"

      This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory. The 4 lines above will, in order:

      • Download the installer to the current directory
      • Verify the installer SHA-384 which you can also cross-check here
      • Run the installer
      • Remove the installer

       

    • Move the composer.phar file into your global path

      sudo mv composer.phar /usr/local/bin/composer
    • Check composer version

       

      composer --version
    • Upgrade composer (If needed)

      sudo -H composer self-update
    • Remove composer in order to re-install a newer version (Do this when upgrade composer command fails)

      sudo rm -f /usr/local/bin/composer

 

  • 4 Install Laravel globally (https://laravel.com/docs/5.8/installation)

    composer global require laravel/installer
  • Add Laravel to global path by adding this line to .bashrc file

    export PATH=~/.composer/vendor/bin:$PATH
  • 5 Switch to a Windows system code folder

    We want to create our code in Windows system, not WSL, so that we can access and edit the code using editor or IDE, and serve the project to localhost and open it on browsers in Windows system.  One good option is the GitHub folder.

    cd /mnt/c/Users/<netID>/Documents/<folder>

     

    • Set up an alias in .bashrc so that you don't have to type the command each time

      alias <name>="cd /mnt/c/Users/<netID>/Documents/<folder>"
  • 6 Start your first Laravel project and serve it

    laravel new <project>

    Local Development Server

    If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://localhost:8000:

    php artisan serve