Laravel Setup Guide on Linux (Zsh-Based)

Dan OngudiDan Ongudi
2 min read

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 with composer -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.

  1. Open .zshrc:

     nano ~/.zshrc
    
  2. Add the following line at the end:

     export PATH="$HOME/.config/composer/vendor/bin:$PATH"
    
  3. Save and exit: CTRL + O, Enter, then CTRL + X.

  4. 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:

  1. Navigate to your Laravel app folder:

     cd example-app
    
  2. Install Sail:

     composer require laravel/sail --dev
    
  3. Generate Sail files:

     php artisan sail:install
    
  4. Start Sail:

     ./vendor/bin/sail up
    

๐Ÿ“Œ Bonus Tips

  • Run composer install after cloning a Laravel project.

  • Set correct permissions for storage/ and bootstrap/cache/:

      sudo chmod -R 775 storage bootstrap/cache
    
  • Use .env to configure your database, email, etc.


๐Ÿ“Ž Common Commands

CommandDescription
php artisan serveRun local dev server
php artisan migrateRun database migrations
php artisan make:controller NameCreate a new controller
php artisan route:listList all routes
composer updateUpdate dependencies

0
Subscribe to my newsletter

Read articles from Dan Ongudi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Dan Ongudi
Dan Ongudi