How to Install Laravel on Linux
- Introduction
- Why Choose Laravel on Linux?
- Prerequisites for Laravel Install on Linux
- Step 1: Installing PHP, Composer, and Laravel Installer on Linux
- Step 2: Installing Node.js and NPM on Linux
- Step 3: Creating a New Laravel Project on Linux
- Step 4: Set Up Your Laravel Development Environment
- Step 5: Configuring Your Database on Linux
Introduction
Are you looking to install Laravel on Linux for your web development projects? Laravel is one of the most popular PHP frameworks, loved for its elegant syntax and powerful features. This guide will walk you through the process step-by-step so you can get started quickly and efficiently.
Why Choose Laravel on Linux?
Laravel is a progressive, scalable, and community-driven web framework designed to make PHP development enjoyable and productive. Linux is an excellent environment for running Laravel applications due to its stability, security, and developer-friendly ecosystem.
By learning how to install Laravel on Linux, you unlock the ability to build modern, full-stack web applications or robust API backends with ease.
Prerequisites for Laravel Install on Linux
Before installing Laravel on your Linux machine, ensure you have the following installed:
- PHP (version 8.1 or above recommended)
- Composer (PHP dependency manager)
- Node.js and NPM (for frontend asset compilation)
If you don’t have PHP and Composer installed, don’t worry! Follow the steps below.
Step 1: Installing PHP, Composer, and Laravel Installer on Linux
Laravel requires PHP and Composer to manage its dependencies. Fortunately, you can install these tools quickly on Linux using the official php.new installation script:
/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
This command will:
- Install PHP 8.4 on your Linux system
- Set up Composer globally
- Install the Laravel installer globally via Composer
Tip: After running the command, restart your terminal session to apply changes.
If you already have PHP and Composer installed, simply run this command to install the Laravel installer:
composer global require laravel/installer
Step 2: Installing Node.js and NPM on Linux
Laravel uses Node.js and NPM to compile frontend assets like CSS and JavaScript. To install them on Linux efficiently, you can use fnm (Fast Node Manager), a lightweight Node.js version manager.
Follow these steps to install Node.js and NPM using fnm:
# Download and install fnm:curl -o- https://fnm.vercel.app/install | bash # Download and install Node.js version 22:fnm install 22 # Verify the installed Node.js version:node -v # Verify the installed npm version:npm -v
After running these commands, you’ll have the latest Node.js 22.x and NPM installed and ready to use for your Laravel project.
Step 3: Creating a New Laravel Project on Linux
Once you have the Laravel installer, you can create a new Laravel application with this simple command:
laravel new example-app
Replace example-app with your desired project name.
The installer will prompt you to choose your preferred testing framework, database, and starter kit options, making the setup process seamless.
Step 4: Set Up Your Laravel Development Environment
Navigate into your new project directory:
cd example-app
Install frontend dependencies and compile assets using npm:
npm install && npm run build
Then, start Laravel's development server with:
composer run dev
Your Laravel application will be accessible at http://localhost:8000.
Step 5: Configuring Your Database on Linux
Laravel uses an SQLite database by default. However, if you want to use MySQL or PostgreSQL, update your .env file with your database credentials:
DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=
Then, run your database migrations to create necessary tables:
php artisan migrate
If you don’t have MySQL or PostgreSQL installed, consider using database management tools like DBngin or Docker on Linux for easier setup.
Stay Updated.
I'll you email you as soon as new, fresh content is published.