How to Install and Set Up Laravel 11 – Complete Step-by-Step Guide (For Future Reference)

If you are planning to start a new Laravel project, this guide will help you install and set up Laravel 11 from scratch. I’m writing this as a proper reference blog so that in the future, everything is available in one place — clean, simple, and practical.

Laravel 11 is lightweight, modern, and optimized for performance. Whether you are using Windows (XAMPP) or Linux/macOS, this guide will walk you through the entire setup process.


What You Need Before Installing Laravel 11

Before starting, make sure your system has the following:

Required Software

  • PHP 8.2 or higher
  • Composer
  • Database (MySQL / MariaDB / PostgreSQL / SQLite)
  • Optional but recommended:
    • Node.js and npm (for frontend assets using Vite)

You can check your PHP version using:

php -v

If PHP version is below 8.2, update it before continuing.


Installing Laravel 11 on Windows (Using XAMPP)

This is the most common setup for local development on Windows.


Step 1: Install XAMPP

Download and install XAMPP.
Make sure Apache and MySQL are running.

Check PHP inside XAMPP:

C:\xampp\php\php -v

If php is not recognized globally, add this path to Environment Variables:

C:\xampp\php

Restart Command Prompt after adding.


Step 2: Install Composer

Download Composer for Windows and install it.

Verify installation:

composer -V

If it shows version, you’re good to go.


Step 3: Create Laravel 11 Project

Go to your web directory:

cd C:\xampp\htdocs

Now create a new project:

composer create-project laravel/laravel myapp

Enter project folder:

cd myapp

Step 4: Setup Environment File and Generate App Key

Laravel usually creates .env automatically. If not:

copy .env.example .env

Now generate application key:

php artisan key:generate

This step is mandatory.


Step 5: Create Database

  1. Open phpMyAdmin
  2. Create database named:
myapp_db

Now open .env file and update:

APP_NAME="MyApp"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp_db
DB_USERNAME=root
DB_PASSWORD=

After editing .env, clear configuration cache:

php artisan config:clear

Step 6: Run Database Migrations

php artisan migrate

If everything is correct, tables will be created successfully.


Step 7: Start Laravel Development Server

php artisan serve

Open in browser:

http://127.0.0.1:8000

Laravel welcome page should appear.


Installing Laravel 11 on Linux / macOS

For VPS or Ubuntu-based systems, follow these steps.


Step 1: Install PHP and Required Extensions (Ubuntu Example)

sudo apt update
sudo apt install php php-cli php-mbstring php-xml php-curl php-zip php-mysql unzip -y

Check PHP version:

php -v

Step 2: Install Composer

If not installed:

sudo apt install composer

Verify:

composer -V

Step 3: Create Laravel Project

composer create-project laravel/laravel myapp
cd myapp

Generate key:

php artisan key:generate

Step 4: Configure Database

Edit .env and update database details.

Then run:

php artisan config:clear
php artisan migrate

Step 5: Run Application

php artisan serve

Open:

http://127.0.0.1:8000

Frontend Setup (Optional but Recommended)

Laravel 11 uses Vite for frontend assets.

Inside project folder:

npm install
npm run dev

For production build:

npm run build

Common Errors and Quick Fixes

Here are common issues and solutions for future reference:


1. APP_KEY not set

php artisan key:generate
php artisan config:clear

2. Changes in .env not reflecting

php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear

3. Class not found error

composer dump-autoload

4. Permission issues on Linux

sudo chmod -R 775 storage bootstrap/cache
sudo chown -R $USER:www-data storage bootstrap/cache

Useful Laravel 11 Commands for Daily Development

Create Controller:

php artisan make:controller HomeController

Create Model with Migration:

php artisan make:model Post -m

Run migrations:

php artisan migrate

Final Thoughts

Laravel 11 installation is straightforward if the environment is properly configured. The key steps are:

  • Install PHP 8.2+
  • Install Composer
  • Create project
  • Configure .env
  • Run migrations
  • Start server

This guide is written as a long-term reference so you don’t have to search again next time.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *