How to Install Laravel: Step-by-Step Guide for Beginners

Reading Time: 2 minutes

Laravel is one of the most popular PHP frameworks used to build modern, secure, and scalable web applications.
It follows the MVC architecture and provides powerful features like routing, authentication, database migrations, and built-in security.

In this guide, you’ll learn how to install Laravel step by step using the recommended methods.


Prerequisites for Installing Laravel

Before installing Laravel, make sure your system has the following:

  • PHP (version 8.1 or higher recommended)
  • Composer
  • Web server (Apache / Nginx)
  • Database (MySQL / MariaDB)

Check PHP Version


php -v

Step 1: Install Composer

Composer is required to install Laravel and manage dependencies.

Download Composer


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Install Composer Globally


php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Verify installation:


composer -V

Step 2: Install Laravel Using Composer

Create a New Laravel Project


composer create-project laravel/laravel myapp

This command:

  • Downloads Laravel
  • Installs dependencies
  • Sets up the project structure

Move into the project:


cd myapp

Step 3: Set File Permissions

Ensure Laravel can write to required directories:


chmod -R 775 storage bootstrap/cache

Step 4: Configure Environment File

Laravel uses a .env file for configuration.

Copy Environment File


cp .env.example .env

Generate Application Key


php artisan key:generate

Step 5: Configure Database

Edit .env file:


DB_DATABASE=myapp_db
DB_USERNAME=myapp_user
DB_PASSWORD=your_password

Run migrations:


php artisan migrate

Step 6: Run Laravel Development Server

Start the built-in server:


php artisan serve

Open in browser:


http://127.0.0.1:8000

You should see the Laravel welcome page 🎉


Alternative Method: Install Laravel Installer

You can also install Laravel globally.


composer global require laravel/installer

Create a new project:


laravel new myapp

Common Issues & Fixes

1. Composer Not Found


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

2. Permission Errors


sudo chown -R $USER:www-data .

3. PHP Extensions Missing

Install required extensions:


php-mbstring php-xml php-curl php-zip

Why Choose Laravel?

Laravel is popular because it offers:

  • Clean and readable syntax
  • Built-in security features
  • Easy database handling
  • Large community support
  • Excellent documentation

It’s suitable for small projects, startups, and enterprise applications.


Final Thoughts

Installing Laravel is straightforward when your environment is properly configured.
With Laravel, you can build modern PHP applications faster and more efficiently.

If you’re new to PHP frameworks, Laravel is an excellent place to start.

Share