How to Install Laravel 12 on Ubuntu 25.04 - Complete Step-by-Step Guide for Developers

How to Install Laravel 12 on Ubuntu 25.04 - Complete Step-by-Step Guide for Developers

Here is a complete guide on   how to install Laravel 12 on Ubuntu 25.04   step-by-step instruction, optimized for Laravel's latest version and Ubuntu's most recent release.

โœ… Prerequisites

Make sure your system is   up-to-date   and you have :

  • Ubuntu 25.04 (clean or updated)
  • A user with 'sudo' privileges
  • Basic familiarity with the terminal

๐Ÿ›  Step 1: Update System

sudo apt update && sudo apt upgrade -y

๐Ÿงฐ Step 2: Install PHP (8.2 or later)

Laravel 12 requires   PHP 8.2 or higher  .

sudo apt install php php-cli php-mbstring php-xml php-bcmath php-curl php-mysql unzip curl git php-tokenizer php-zip -y

โœ… Check PHP version:

php -v

โœ… Step 3: Install Composer (Dependency Manager)

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

โœ… Step 4: Install Laravel Installer (Globally)

composer global require laravel/installer

Make sure `~/.composer/vendor/bin` or `~/.config/composer/vendor/bin` is in your `PATH`. Add this to your `~/.bashrc` or `~/.zshrc`:

export PATH="$HOME/.config/composer/vendor/bin:$PATH"

Apply the changes:

source ~/.bashrc   # or source ~/.zshrc

๐Ÿ“‚ Step 5: Create New Laravel Project

laravel new myproject

Or using Composer directly:

composer create-project laravel/laravel myproject

Navigate to project:

cd myproject

๐ŸŒ Step 6: Serve Laravel Project

Use Laravel's built-in server:

php artisan serve

Your app will be running at:

http://localhost:8000

๐Ÿงช Step 7 (Optional): Setup Database (MySQL)

Install MySQL:

sudo apt install mysql-server

Secure it:

sudo mysql_secure_installation

Create a database:

sudo mysql -u root -p
CREATE DATABASE laravel_db;

Edit '.env' in your project root:

DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=your_password

Run migrations:

php artisan migrate

๐ŸŽ‰ Done!

Laravel 12 is now installed and running on   Ubuntu 25.04  .

Tags :