Laravel Setup Guide on Linux (Zsh-Based)
Prerequisites
Before starting, make sure your system has the following installed:
- PHP 8.1 or higher (including extensions like
mbstring,curl,openssl,pdo, etc.) - Composer (dependency manager for PHP)
- Git
- Zsh shell (you’re already using it)
Install them (on Debian/Ubuntu-based distros):
sudo apt update
sudo apt install php php-cli php-mbstring php-xml php-bcmath php-curl php-zip unzip curl git zsh💡 Tip: You can check PHP version with
php -vand Composer version withcomposer -V.
Step 1: Install Laravel Installer Globally
Run this command:
composer global require laravel/installerThis installs the Laravel installer in the Composer global directory.
Step 2: Add Composer's Global Bin to Your PATH
Your global Laravel command is located at:
/home/your-username/.config/composer/vendor/binTo make the laravel command available system-wide, add this path to your ~/.zshrc.
- Open
.zshrc:
nano ~/.zshrc- Add the following line at the end:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"- Save and exit:
CTRL + O,Enter, thenCTRL + X. - Reload your terminal config:
source ~/.zshrcStep 3: Verify Laravel Installer
Now confirm it's working:
laravel --versionYou should see:
Laravel Installer 5.16.0Step 4: Create a New Laravel Project
Navigate to your development directory and run:
laravel new project-nameExample:
cd ~/projects
laravel new example-appThis will create a new Laravel app in ~/projects/example-app.
Step 5: Serve the Application (Local Dev Server)
You can start Laravel's built-in development server:
cd example-app
php artisan serveBy default, it runs at:
📍 http://localhost:8000
Optional: Run Laravel with Sail (Docker)
If you prefer a Docker-based dev environment:
- Navigate to your Laravel app folder:
cd example-app- Install Sail:
composer require laravel/sail --dev- Generate Sail files:
php artisan sail:install- Start Sail:
./vendor/bin/sail up📌 Bonus Tips
- Run
composer installafter cloning a Laravel project. - Set correct permissions for
storage/andbootstrap/cache/:
sudo chmod -R 775 storage bootstrap/cache- Use
.envto configure your database, email, etc.
📎 Common Commands
| Command | Description |
|---|---|
php artisan serve |
Run local dev server |
php artisan migrate |
Run database migrations |
php artisan make:controller Name |
Create a new controller |
php artisan route:list |
List all routes |
composer update |
Update dependencies |