Skip to content

A complete step-by-step setup of the ALTERC Laravel project on **WSL (Ubuntu)** using Apache, MySQL, phpMyAdmin, and optional Redis. It is structured for practical future reference.

Notifications You must be signed in to change notification settings

learnwithfair/laravel-setup-in-WSL-Ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Youtube Facebook Instagram LinkedIn

Thanks for visiting my GitHub account!

Laravel Project Setup Guide in WSL (Ubuntu) with (Apache + MySQL + phpMyAdmin + Redis)

A complete step-by-step setup of the ALTERC Laravel project on WSL (Ubuntu) using Apache, MySQL, phpMyAdmin, and optional Redis. It is structured for practical future reference.

Table of Contents

  1. System Requirements
  2. WSL & Ubuntu Setup
  3. Apache Web Server Configuration
  4. MySQL Setup & Root Access Fix
  5. phpMyAdmin Configuration
  6. Redis (Optional)
  7. Laravel Project Setup
  8. Vite & NPM
  9. Launch the Project
  10. Access from Browser
  11. Common Commands
  12. Troubleshooting

0. System Requirements

  • Windows 10/11 with WSL2 enabled
  • Ubuntu via WSL
  • Node.js (18.x LTS preferred)
  • PHP 8.1+
  • MySQL (inside WSL)
  • Apache2 (inside WSL)
  • phpMyAdmin (inside WSL)

1. WSL Installation & Ubuntu Setup

  • Open terminal (command prompt) and run
wsl --install

Launch Ubuntu terminal by search ubuntu in search bar and set up your user.


Installing Dependencies

  • Open Ubuntu Terminal.
sudo apt update && sudo apt upgrade
sudo apt install php php-mysql php-xml php-mbstring php-curl unzip curl mysql-server apache2 phpmyadmin npm nodejs

2. Apache Web Server Configuration

sudo apt install apache2 -y
sudo service apache2 restart

To restart manually:

sudo service apache2 restart

3. MySQL Setup & Root Access Fix

sudo apt install mysql-server -y
sudo service mysql start

To login securely:

sudo mysql

Then run:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';
FLUSH PRIVILEGES;
EXIT;

Now you can log in normally:

mysql -u root -p
# Password: 12345678

Create a new user for phpMyAdmin:

CREATE USER IF NOT EXISTS 'phpmyadmin'@'localhost' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

4. phpMyAdmin Configuration

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
sudo phpenmod mbstring
sudo service apache2 restart

Enable phpMyAdmin in Apache:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo service apache2 restart

Access: http://localhost/phpmyadmin

5. Redis (Optional)

sudo apt install redis-server -y
sudo service redis-server start
  • Then test Redis:
redis-cli ping
  • Expected output:
PONG
  • Test Redis connection from Laravel:
php artisan cache:clear

6. Laravel Project Setup

Cloning or Copying Project:

cd ~
git clone https://your-repo-link.git alterc
cd alterc

Or if already placed:

cd ~/alterc
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate --seed

Open Source code in VS code

cd ~/alterc
code .

Accessing Project Files from Windows

In WSL:

explorer.exe .

Or from Windows:

\\\\wsl.localhost\\Ubuntu\\home\\learnwithfair\\alterc

Make .env changes:

DB_DATABASE=alterc
DB_USERNAME=phpmyadmin
DB_PASSWORD=12345678

7. Vite & NPM

Inside the Laravel project:

Terminal 1:

rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
npm run dev

Vite Development Server

  • npm run dev for development.
  • npm run build for production build.

8. Launch the Project (Custom domain)

Terminal 2:

php artisan serve --host=superadmin.trekntread.com --port=8000

You may add to /etc/hosts: (Custom domain)

127.0.0.1 superadmin.trekntread.com

9. Access from Browser

Visit: http://superadmin.trekntread.com:8000

If redirected to HTTPS, check Laravel .env:

APP_URL=http://superadmin.trekntread.com:8000

And clear config cache:

php artisan config:clear
php artisan cache:clear

10. Common Commands

Action Command
Restart Apache sudo service apache2 restart
Stop Apache sudo service apache2 stop
Start MySQL sudo service mysql start
Stop MySQL sudo service mysql start
Start Redis Server sudo service redis-server stop
Stop Redis Server sudo service redis-server stop
Laravel migration php artisan migrate --seed
Clear config/cache php artisan config:clear && php artisan cache:clear
Start dev server (vite) npm run dev
Start Laravel server php artisan serve

11. Troubleshooting

  • NPM Error UNC paths: Ensure you're not running npm commands from a Windows CMD if using WSL. Always use Ubuntu terminal.
  • Redis error: If not used, disable Redis config or install Redis as shown.
  • Port Conflicts: Use different ports or stop conflicting services (like XAMPP/Apache).

✅ All done. Your Laravel + Vite project is now fully configured in WSL with Apache2, MySQL, and phpMyAdmin support.

Follow Me

github facebook instagram twitter YouTube

About

A complete step-by-step setup of the ALTERC Laravel project on **WSL (Ubuntu)** using Apache, MySQL, phpMyAdmin, and optional Redis. It is structured for practical future reference.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published