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 |
lsb_release -a |
sudo add-apt-repository ppa:ondrej/php sudo apt-get update |
sudo apt-get install php7.3 |
Check php version
php -v |
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 |
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:
sudo mv composer.phar /usr/local/bin/composer |
composer --version |
sudo -H composer self-update |
sudo rm -f /usr/local/bin/composer |
composer global require laravel/installer |
Add Laravel to global path by adding this line to .bashrc file
export PATH=~/.composer/vendor/bin:$PATH |
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>" |
laravel new <project> |
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 |