Step‑by‑Step Guide to Installing and Configuring Laravel

This guide walks you through Laravel's server requirements, installation via Composer or the Laravel installer, local development setup, essential configuration such as public path, permissions, application key, and web‑server tweaks for Apache and Nginx, providing ready‑to‑use code snippets.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Step‑by‑Step Guide to Installing and Configuring Laravel

Installation

Server Requirements

Laravel requires PHP >= 7.2.0 and the following extensions:

BCMath

Ctype

JSON

Mbstring

OpenSSL

PDO

Tokenizer

XML

Install Laravel

Using the Laravel Installer (Windows/macOS)

First install the installer globally with Composer: composer global require laravel/installer Ensure the Composer vendor‑bin directory is in your $PATH. Typical locations are:

macOS / Linux: $HOME/.config/composer/vendor/bin Windows: %USERPROFILE%\AppData\Roaming\Composer\vendor\bin Then create a new project: laravel new blog This creates a blog directory with all Laravel dependencies installed.

Creating a Project via Composer

Alternatively, run the Composer create-project command:

composer create-project --prefer-dist laravel/laravel blog

Local Development Environment

If PHP is installed locally, you can serve the application with Artisan: php artisan serve The built‑in server listens at http://localhost:8000. For a more robust environment, consider using Homestead or Valet.

Configuration

Public Path

Set the web server’s document root to the public directory. The public/index.php file acts as the front controller for all HTTP requests.

Configuration Files

All framework configuration files reside in the config directory, each containing documented options.

Directory Permissions

Make the storage and bootstrap/cache directories writable by the web server; otherwise Laravel will not run. Homestead configures these permissions automatically.

Application Key

Laravel generates a random 32‑character key during installation. If you used the installer or Composer, the key is already set via: php artisan key:generate The key is stored in the .env file. If .env does not exist, copy .env.example to .env. Without a proper key, encrypted data and sessions are insecure.

Other Settings

Review config/app.php for options such as timezone and locale. Additional components such as cache, database connections, and session handling can also be configured.

Web Server Configuration

Pretty URLs – Apache

Laravel ships with public/.htaccess to hide index.php. Ensure the mod_rewrite module is enabled.

If the default file does not work, use the following directives:

Options +FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Pretty URLs – Nginx

Add a location block that forwards all requests to index.php:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
Nginx configuration example
Nginx configuration example
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend DevelopmentPHPWeb serverInstallationLaravel
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.