Installing Laravel: Complete Step-by-Step Guide for Beginners (2025)

Laravel has become one of the most widely used PHP frameworks for modern web development. Developers prefer it because of its elegant syntax, MVC architecture, and rich set of features that simplify common tasks like authentication, routing, and database management. However, before you can enjoy its powerful capabilities, you need to install Laravel correctly on your system.
This step-by-step guide to installing Laravel will walk you through every detail: system requirements, PHP setup, Composer installation, server configuration, and creating your first Laravel project. Whether you’re a beginner or an experienced developer, this article ensures you don’t miss a step.
Why Choose Laravel?
Before diving into installation, it’s important to understand why Laravel is such a popular framework:
- MVC Architecture: Keeps business logic, presentation, and database layers separate.
- Eloquent ORM: Simplifies database interactions with expressive syntax.
- Blade Template Engine: Makes front-end rendering easier.
- Built-in Security: Includes CSRF protection, password hashing, and more.
- Artisan CLI: A command-line tool to speed up development tasks.
- Community & Ecosystem: Large, active community with packages, tutorials, and support.
With these advantages, Laravel is the go-to choice for building scalable, modern PHP applications.
Step 1: Check System Requirements
The first step in installing Laravel is ensuring your system meets the required environment. Laravel 10 (latest as of 2025) requires:
- PHP: 8.1 or higher
- Composer: Dependency manager for PHP
- Database: MySQL 5.7+, PostgreSQL 10+, SQLite, or SQL Server
- Web Server: Apache or Nginx
- PHP Extensions:
- OpenSSL
- PDO
- Mbstring
- Tokenizer
- XML
- Ctype
- JSON
- BCMath
Check PHP version with:
php -v
If you don’t have PHP installed, get it from the official PHP downloads page or via package managers like apt
(Linux) or brew
(macOS).
Step 2: Install Composer
Composer is essential for managing Laravel’s dependencies. Without it, you cannot install Laravel or its packages.
Windows
- Download the installer from getcomposer.org.
- During installation, select the PHP executable path.
- Verify installation:
composer -V
macOS / Linux
Run these commands in your terminal:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
Check version:
composer -V
If it shows a version number, Composer is installed correctly.
Step 3: Set Up Web Server and Database
Laravel requires a web server (Apache, Nginx) and a database (MySQL, PostgreSQL, etc.). There are multiple ways to configure this:
Option 1: XAMPP (Windows, macOS, Linux)
- Comes pre-packaged with Apache, MySQL, and PHP.
- Start Apache and MySQL from the XAMPP Control Panel.
- Access http://localhost/phpmyadmin to manage databases.
Option 2: Laragon (Windows)
- Lightweight and Laravel-friendly.
- Offers one-click installation for PHP, MySQL, and Apache/Nginx.
Option 3: Laravel Valet (macOS/Linux)
- Minimalistic environment that automatically serves applications at
http://project.test
.
Step 4: Installing Laravel
There are two main methods for installing Laravel:
Method 1: Composer Create-Project
composer create-project laravel/laravel project-name
This installs Laravel in a folder named project-name
.
Method 2: Laravel Installer
Install globally:
composer global require laravel/installer
Then create a new project:
laravel new project-name
Both methods will generate a fresh Laravel project.
Step 5: Configure Laravel Environment
Laravel uses a .env
file for environment configuration. After installation, navigate to your project folder:
cd project-name
Update .env
file:
APP_NAME=MyLaravelApp APP_ENV=local APP_KEY=base64:generatedkey APP_DEBUG=true APP_URL=http://localhost DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=root DB_PASSWORD=
Make sure the database exists. Create it in phpMyAdmin or with MySQL CLI:
CREATE DATABASE laravel_db;
Step 6: Run Laravel Development Server
Laravel has a built-in development server. Start it with:
php artisan serve
Output:
Starting Laravel development server: http://127.0.0.1:8000
Visit the URL, and you’ll see Laravel’s welcome page. 🎉
Step 7: Database Migrations
Instead of manually creating tables, Laravel uses migrations.
Create migration:
php artisan make:migration create_posts_table
Run migrations:
php artisan migrate
This will create default tables (users
, password_resets
, failed_jobs
) along with your custom migration.
Step 8: Handling Common Installation Issues
Problem 1: Composer Memory Limit Error
php -d memory_limit=-1 composer create-project laravel/laravel project-name
Problem 2: File Permission Issues (Linux/Mac)
sudo chown -R $USER:www-data storage bootstrap/cache
Problem 3: Missing Extensions
Enable missing PHP extensions (like openssl
, pdo_mysql
) in php.ini
.
Step 9: Using Laravel Sail (Docker Alternative)
For developers who prefer Docker, Laravel Sail is a lightweight option.
Install via Sail:
curl -s https://laravel.build/project-name | bash cd project-name ./vendor/bin/sail up
This sets up Laravel with Docker containers for MySQL, Redis, and other services.
Step 10: Post-Installation Essentials
After installing Laravel, here are crucial steps to follow:
Generate App Key
php artisan key:generate
Install Node.js & NPM
Laravel uses Vite for front-end assets. Install:
npm install npm run dev
Learn Artisan CLI
Check available commands:
php artisan list
Laravel Installation Best Practices
- Always use Composer create-project instead of cloning GitHub repos.
- Keep
.env
file secure and never commit it to Git. - Regularly update dependencies with:
composer update
- Use version control (Git) for your projects.
- For production, configure Apache/Nginx Virtual Hosts instead of
php artisan serve
.
Advanced Installation Options
Installing Specific Laravel Version
composer create-project laravel/laravel="9.*" project-name
Installing Laravel with Jetstream
For authentication scaffolding:
composer require laravel/jetstream php artisan jetstream:install livewire npm install && npm run dev php artisan migrate
Installing Laravel with Breeze (Lightweight Auth)
composer require laravel/breeze --dev php artisan breeze:install npm install && npm run dev php artisan migrate
Conclusion
By now, you should have a complete understanding of how to install Laravel step by step. From setting up PHP and Composer to configuring your database and running the development server, you’re fully prepared to begin your Laravel journey.Laravel’s flexibility, powerful tools, and ease of setup make it one of the best frameworks for building web applications in 2025. Whether you’re developing a personal project or a large enterprise system, Laravel provides the foundation to scale and succeed.
Comments (0)