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 -v
and Composer version withcomposer -V
.
Step 1: Install Laravel Installer Globally
Run this command:
composer global require laravel/installer
This 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/bin
To 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 ~/.zshrc
Step 3: Verify Laravel Installer
Now confirm it's working:
laravel --version
You should see:
Laravel Installer 5.16.0
Step 4: Create a New Laravel Project
Navigate to your development directory and run:
laravel new project-name
Example:
cd ~/projects
laravel new example-app
This 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 serve
By 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 install
after cloning a Laravel project.Set correct permissions for
storage/
andbootstrap/cache/
:sudo chmod -R 775 storage bootstrap/cache
Use
.env
to 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 |
Subscribe to my newsletter
Read articles from Dan Ongudi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
