Thanks for visiting my GitHub account!
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.
- System Requirements
- WSL & Ubuntu Setup
- Apache Web Server Configuration
- MySQL Setup & Root Access Fix
- phpMyAdmin Configuration
- Redis (Optional)
- Laravel Project Setup
- Vite & NPM
- Launch the Project
- Access from Browser
- Common Commands
- Troubleshooting
- 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)
- Open terminal (command prompt) and run
wsl --install
Launch Ubuntu terminal by search ubuntu in search bar and set up your user.
- 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
sudo apt install apache2 -y
sudo service apache2 restart
To restart manually:
sudo service apache2 restart
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;
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
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
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
cd ~/alterc
code .
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
Inside the Laravel project:
Terminal 1:
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
npm run dev
npm run dev
for development.npm run build
for production build.
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
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
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 |
- 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.