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
- Put
export PATH=~/.config/composer/vendor/bin:$PATH
- 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
- Add
127.0.0.1 example-app.test
to your Windows HOST file - Navigate to
http://example-app.test
to check
Using Sail, Docker and NGROK
- Install Docker
- 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
- Navigate to your Laravel Project and install Sail Scaffold
php artisan sail:install
./vendor/bin/sail up
- 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
- 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