Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • 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.

    Code Block
    sudo apt-get update 
    sudo apt-get dist-upgrade

     

    • How to check current version of Ubuntu
      Code Block
      lsb_release -a

 

  • 2 Install PHP7.3 

     

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

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

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

        Code Block
        php -v
    • Installing PHP 7.3 Extensions

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

      Code Block
      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

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

       

      Code Block
      composer --version
    • Upgrade composer (If needed)

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

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

 

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

    Code Block
    composer global require laravel/installer
  • 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.

    Code Block
    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

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

    Code Block
    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:

    Code Block
    php artisan serve

     

     

...