Quick Summary
This guide provides a clear, step-by-step process for installing the Laravel framework on Windows, macOS, and Linux. We cover all prerequisites, including PHP and Composer, and walk you through creating a new project. You’ll also find solutions to common installation errors, ensuring a smooth setup for your development environment.
Table of Contents
Building a new web application starts with choosing the right framework. Laravel is one of the best options available, thanks to its clean syntax, robust tools, and rapid development. Its ability to streamline complex tasks makes it a web development experts’ favorite.
Whether you are building a basic, small prototype or an enterprise-level solution, the procedure starts with installing Laravel. It can vary depending on your operating system, with subtle differences between Windows, macOS, and Linux.
This guide breaks down how to install Laravel, from the prerequisites to installation and new project setup. But first, let’s look at a brief overview of Laravel.
What is Laravel?
Laravel is a free, open-source PHP web framework designed for building modern, robust web applications and APIs. The best highlight of Laravel is that it’s essentially a toolkit. This framework offers a foundation such that you don’t have to start from scratch.
This platform can streamline common tasks like routing, authentication, sessions, caching, and database interactions. Laravel’s expressive, elegant syntax and powerful PHP features help with that.
Key Features of Laravel
The features of Laravel are all focused on simplifying the workflow and speeding up the web application development. Let’s look at the key ones.
MVC Architecture
Laravel follows the MVC pattern, separating application logic (Model), user interface (View), and input control (Controller). It ensures better clarity, scalability, and maintainability.
Blade Templating Engine
Laravel offers a built-in Blade templating engine. Developers use it to create reusable and dynamic layouts using simple PHP-like syntax. It integrates seamlessly with frontend frameworks like Vue.js and React.
Eloquent ORM
Eloquent is Laravel’s object-relational mapper. Developers use the Laravel Eloquent ORM tactics to interact with databases through expressive PHP syntax rather than raw SQL. It supports relationships, eager loading, and data manipulation elegantly.
Artisan CLI
Artisan is Laravel’s built-in command-line tool. It helps automate repetitive tasks like migrations, seeding, and creating boilerplate code. Developers can even define custom commands to streamline their workflow.
Routing System
Laravel offers a highly-intuitive routing mechanism that maps URLs to controller actions or closures. It enables RESTful route definitions and reverse routing for easy URL management.
Authentication & Authorization
Laravel includes built-in systems for user authentication, password reset, and role-based access control. It simplifies secure app development.
Validation Engine
The validation component offers a concise and flexible mechanism to validate form inputs. It supports predefined and custom validation rules.
Event Handling & Queues
Laravel supports event-driven programming and includes a queue system. They handle background jobs like sending emails or processing uploads asynchronously. That improves the performance and user experience.
Built-in Testing
Laravel integrates with PHPUnit for unit and feature testing. You also get platforms like Laravel Dusk and BrowserKit for end-to-end browser testing to ensure software reliability.
There are several other top features that make Laravel one of the top web development platforms. Developers use them in tandem to build the best web applications.
Prerequisites for Laravel Installation
Before installing Laravel, your system must meet specific technical requirements. This framework is built on PHP and relies on a few core dependencies. Make sure all these are properly taken care of for a smooth setup.
For Windows
The simplest method on Windows is to use the official Laravel installer.
- PHP: Install a recent version of PHP (8.1+). The easiest way is to use XAMPP or WAMP, which bundle PHP, a database, and a web server.
- Composer: Download and run the Windows Composer installer. If you prefer using the command line, follow this step-by-step guide to install Laravel using Composer for a seamless setup process.
- Database: Your XAMPP/WAMP installation includes MySQL/MariaDB. SQLite is also available by default with PHP.
For macOS
macOS has multiple installation paths, with Homebrew being the most streamlined.
- Homebrew: Install the Homebrew package manager.
- PHP: Install PHP using Homebrew: brew install php.
- Composer: Install Composer globally via Homebrew: brew install composer.
- Database: Install your preferred database (e.g., brew install mysql or brew install sqlite).
For Linux
Requirements vary by distribution. If you’re working with Ubuntu, check out the process on how to install Laravel on Ubuntu for a quick, terminal-based setup experience. The following are for Ubuntu-based systems.
- PHP: Install PHP and necessary extensions: sudo apt install php php-cli php-mbstring php-xml php-zip php-pdo php-sqlite3 php-mysql
- Composer: Install Composer by following the official installation guide for Linux.
- Database: Install your chosen database server, for example:
- MySQL: sudo apt install mysql-server
- SQLite: sudo apt install sqlite3 (often pre-installed)
Once these prerequisites are met, you can proceed with the installation and project setup. If your application needs to be hosted within an existing directory, need to know how to install Laravel in subdirectory for smoother integration with your existing project structure.
How to Install Laravel on Windows?
We’ll follow the most straightforward method of installing Laravel, i.e. leveraging XAMPP and Composer.
Step 1: Install XAMPP
XAMPP provides the essential foundation: a PHP interpreter and a MySQL database.

- Go to the Apache Friends XAMPP page.
- Download the installer for the latest version of PHP 8.1 or higher.
- Run the downloaded .exe file. During installation:
- You may get a User Account Control (UAC) warning; click “Yes.”
- When prompted, install all components (MySQL, Apache, PHP are critical).
- Choose an installation folder (the default C:\xampp\ is recommended).
After installation, open the ‘XAMPP Control Panel’ and start the ‘Apache’ and ‘MySQL’ modules.
Step 2: Install Composer

Composer is the dependency manager Laravel uses for installation and package management.
- Go to the Composer home page.
- Click on ‘Download’ and then the ‘Composer-Setup.exe’ link.
- Run the installer and follow the on-screen instructions.
It will automatically detect your XAMPP PHP installation. Just accept the default settings.
Step 3: Verify Composer Installation
This confirms Composer is correctly installed and in your system’s PATH.
- Open Command Prompt (press ‘Win + R’, type cmd, and press ‘Enter’).
- Type the following command and press Enter:
composer --version
You should see the installed Composer version number. If you get an error, try restarting your command prompt or PC.
Step 4: Install Laravel Using Composer
You will now use Composer to create a new Laravel project.
In your Command Prompt, navigate to the directory where you want to create your project (e.g., your htdocs folder or your desktop). For example, to go to htdocs:
cd C:\xampp\htdocs
Run the following Composer command to create a new Laravel project named my-laravel-app:
composer create-project laravel/laravel my-laravel-app
Composer will now download Laravel and all its dependencies. This may take a few minutes.
Step 5: Verify Laravel Installation
Ensure the installation is completed without errors. For that, navigate into your new project directory:
cd my-laravel-app
List the contents to confirm key Laravel files (like artisan and the app directory) are present.
Step 6: Start the Development Server
Laravel includes a built-in development server for testing. From within your project directory (my-laravel-app), run the following Artisan command:
php artisan serve
The server will start, and you will see an output similar to:
Starting Laravel development server: http://127.0.0.1:8000
Step 7: Run the Project in Your Browser
Open your web browser (e.g., Chrome, Firefox). Go to the address provided by the artisan serve command: http://127.0.0.1:8000.
You should see the default Laravel welcome page, confirming a successful installation.
Now, your local Laravel development environment is fully set up and ready. You can start building the web application.
How to Install Laravel on macOS?
This guide uses Homebrew, the standard package manager for macOS. It helps create a clean and manageable development environment.
Step 1: Install Homebrew (if not already installed)
Homebrew simplifies the installation of software on macOS.
- Open the ‘Terminal’ application (you can find it via Spotlight search: Cmd + Space, type “Terminal”).
- Paste the following command and press ‘Enter’:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Follow the on-screen prompts. This will also install the Xcode Command Line Tools if they aren’t already present.
Step 2: Install PHP
Use Homebrew to install the latest stable version of PHP. In your terminal, run:
brew install php
Once complete, this will provide a fully configured PHP environment. You can verify the active version with php -v.
Step 3: Install Composer
Composer is the dependency manager for PHP and is required to install Laravel. While still in Terminal, use Homebrew to install Composer globally:
brew install composer
Step 4: Verify PHP & Composer Installations
Confirm that both tools are correctly installed and accessible. Run these commands to check their versions:
php -v
composer --version
You should see version numbers for both without any errors.
Step 5: Install Laravel Using Composer
You can now use Composer to create a new Laravel project. Navigate to the directory where you keep your projects (e.g., Sites in your home folder):
cd ~/Sites
Run the Composer create-project command to install Laravel into a new directory named my-app:
composer create-project laravel/laravel my-app
Composer will download all necessary dependencies. This process may take several minutes.
Step 6: Verify Laravel Installation
Ensure the project was created successfully. Navigate into your new project directory:
cd my-app
You can list the files (ls -la) to see the Laravel project structure, including the artisan script.
Step 7: Install Node.js and npm (Optional but Recommended)
While not required for the core Laravel installation, you will need Node.js and npm to compile front-end assets like CSS and JavaScript.
Install Node.js, which includes npm, via Homebrew:
brew install node
Verify the installation with: node -v and npm -v.
Step 8: Start the Development Server
Laravel includes a built-in development server for local testing. From within your Laravel project directory (my-app), run:
php artisan serve
The terminal will display a message:
Starting Laravel development server: http://127.0.0.1:8000
Step 9: Run the Project in Your Browser
Open your web browser and visit http://127.0.0.1:8000. You will see the default Laravel welcome page, indicating a successful installation.
Your macOS machine is now ready for Laravel development. You can begin building your application in the my-app directory.
How to Install Laravel on Linux?
This guide provides a complete LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack setup for a robust Laravel development environment on Linux.
Step 1: Update Your System
Start by ensuring your system packages are up-to-date.
sudo apt update && sudo apt upgrade -y
Step 2: Install Apache Web Server
Install Apache to serve your Laravel application.
sudo apt install apache2 -y
Once installed, you can start and enable Apache to run on boot:
sudo systemctl start apache2
sudo systemctl enable apache2
You can verify it’s working by visiting http://your_server_ip in a browser.
Step 3: Install PHP and Required Extensions
Laravel requires PHP 8.1 or higher along with specific extensions.
sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-bcmath php-json php-tokenizer php-ctype php-fileinfo -y
Step 4: Install MariaDB Database Server
Install MariaDB (a drop-in replacement for MySQL) as your database.
sudo apt install mariadb-server mariadb-client -y
Secure the installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and secure the configuration.
Step 5: Install Composer
Composer is essential for managing Laravel’s dependencies.
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Step 6: Verify PHP, MariaDB, and Composer Installations
Confirm all components are installed correctly.
php -v
mariadb --version
composer --version
Step 7: Install Laravel Using Composer
Create a new Laravel project. It’s common practice to place projects in the /var/www/ directory.
cd /var/www
sudo composer create-project laravel/laravel my-app
Step 8: Set Correct Permissions
The storage and bootstrap/cache directories need to be writable by the web server.
cd my-app
sudo chown -R www-data:www-data .
sudo chmod -R 775 storage
sudo chmod -R 775 bootstrap/cache
Step 9: Configure Apache Virtual Host (Optional but Recommended)
For a proper development environment, create an Apache configuration file for your site.
sudo nano /etc/apache2/sites-available/my-app.conf
Add the following configuration, replacing your_server_domain_or_IP with your actual domain or local IP (e.g., laravel.test or 127.0.0.1):
<VirtualHost *:80>
ServerName your_server_domain_or_IP
DocumentRoot /var/www/my-app/public
<Directory /var/www/my-app/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site and the mod_rewrite module, then restart Apache:
sudo a2ensite my-app.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 10: Run the Laravel Server (Alternative for Quick Testing)
If you haven’t configured Apache, you can use Laravel’s built-in server for immediate testing.
cd /var/www/my-app
php artisan serve --host=0.0.0.0
This will make the application accessible at http://your_server_ip:8000.
Your Laravel application is now installed and running on your Linux server. You can access it via the domain you configured or the artisan serve command.
How to Create a New Laravel Project?
Creating a new Laravel project is a straightforward process, primarily accomplished using Composer. The method you choose depends on your preferred workflow and whether you need global access to the Laravel installer.
Method 1: Using Composer’s create-project (The Universal Method)
This is the most reliable and universally supported method, as it uses Composer directly. It requires no prior global installation.
Step 1: Open your terminal (Command Prompt on Windows, Terminal on macOS/Linux).
Step 2: Navigate to the directory where you want to create your project (e.g., cd ~/Sites or cd C:\xampp\htdocs).
Step 3: Run the Composer command:
composer create-project laravel/laravel your-project-name
Replace your-project-name with the desired name for your project folder (e.g., my-blog, awesome-app).
Step 4: Wait for installation. Composer will create the directory, download the latest version of Laravel, and install all its dependencies. This may take several minutes.
Method 2: Using the Laravel Installer (The Quickest Method)
This method is faster and more convenient if you plan to create multiple projects. It requires a one-time global installation.
Step 1: Install the Laravel Installer globally via Composer:
composer global require laravel/installer
Ensure your Composer global bin directory is in your system’s PATH.
Step 2: Navigate to your desired parent directory in the terminal.
Step 3: Create a new project with the installer:
laravel new your-project-name
This command is significantly faster than composer create-project.
Method 3: Using Laravel Sail (For Docker-Based Development)
Laravel Sail provides a lightweight command-line interface for interacting with Laravel’s default Docker development environment. This is ideal if you want a consistent environment without installing PHP/Composer locally.
Step 1: Navigate to your desired parent directory.
Step 2: Create a new project using Sail. If you have Composer installed locally:
composer create-project laravel/laravel your-project-name
cd your-project-name
php artisan sail:install
Alternatively, you can use Curl to create the project without a local PHP installation (on macOS/Linux):
curl -s https://laravel.build/your-project-name | bash
Your new Laravel application is now ready for development. You can begin building by editing the files in the routes/, resources/views/, and app/ directories.
Common Installation Errors & Troubleshooting
Even after following the due procedures, there may be some errors. So here we look at the most frequent issues and their solutions.
Composer Version or Memory Limit Error
Error
Composer is not recognized as an internal or external command
Or
proc_open(): fork failed - Cannot allocate memory.
Cause: Composer is not installed correctly, not in your system’s PATH, or it’s running out of memory.
Solution
- “Not recognized” error: Reinstall Composer, ensuring you check the box to “Add to PATH” during setup on Windows. On macOS/Linux, verify the installation path.
- Memory Limit error: Increase PHP’s memory limit for Composer temporarily:
COMPOSER_MEMORY_LIMIT=-1 composer create-project laravel/laravel your-project-name
PHP Version Error
Error
laravel/laravel [...] requires php ^8.1 [...] your php version (8.0.X) does not satisfy that requirement.
Cause: Your system is running an outdated, unsupported version of PHP.
Solution
- Windows/Mac: Reinstall XAMPP or use Homebrew to get PHP 8.1+.
- Linux: Use a PPA to install a newer PHP version.
- Verify the active PHP version using php -v in your terminal. Ensure your web server (like Apache) is also using the correct version.
Missing PHP Extensions
Error
the requested PHP extension bcmath is missing from your system
Or similar for mbstring, xml, zip, etc.
Cause: Laravel requires several PHP extensions that are not enabled by default in some environments.
Solution
- Windows: Uncomment the corresponding lines (e.g., extension=mbstring) in your php.ini file and restart Apache.
- macOS/Linux: Install the missing extensions via your package manager. For example, on Ubuntu:
sudo apt install php-bcmath php-mbstring php-xml php-zip php-curl php-tokenizer
File Permission Errors (Primarily Linux/macOS)
Error
The Laravel welcome page loads, but you see errors about being unable to write to the log or generating a storage link.
Cause: The web server user (e.g., www-data) does not have write permissions to the storage and bootstrap/cache directories.
Solution
Navigate to your Laravel project root and run these commands:
sudo chown -R $USER:www-data .
chmod -R 775 storage
chmod -R 775 bootstrap/cache
SSL Certificate Error (cURL error 60)
Error
cURL error 60: SSL certificate problem: unable to get local issuer certificate
Cause: Composer cannot verify the SSL certificates of the packages it’s trying to download, often on local Windows environments like XAMPP.
Solution
- Download a fresh cacert.pem file from curl.haxx.se/docs/caext.html.
- Open your php.ini file and add/update this line with the correct path:
curl.cainfo = "C:\path\to\your\cacert.pem"
- Restart your web server.
“The Process Class” Dependency Error on Windows
Error
Fatal error related to symfony/process during php artisan commands.
Cause: A known compatibility issue between Windows and the Symfony Process component.
Solution
- Open composer.json in your project root.
- Add the following line to the “require” section:
"symfony/process": "^5.0"
- Run composer update in your terminal.
If the particular error you are facing isn’t listed here, try to verify your prerequisites, clear Composer cache, and check for any possible typos.
And if you want help with ensuring an error-free setup and development, consult with a dedicated Laravel development company.
Let’s Conclude
Laravel is an excellent framework for creating dynamic websites and web apps. But to install it in your development environment, there are some prerequisites.
The core requirements (PHP and Composer) remain the same across all operating systems. However, there are slight variations in the installation methods:
- Windows: WSL2 (Windows Subsystem for Linux 2) is the recommended approach, offering a familiar Linux environment for installing PHP and Composer. Alternatively, direct PHP installation using XAMPP/MAMP is possible.
- macOS: Homebrew, a popular package manager, simplifies the installation of PHP and Composer on macOS.
- Linux: Utilize your distribution’s built-in package manager (e.g., apt-get, yum) to install PHP and Composer.
For guidance and support with Laravel installation and development, hire dedicated Laravel developers today!
FAQs on Laravel Installation
Do I need to be a PHP expert to install Laravel?
No. While basic command-line familiarity is helpful, the installation process is procedural. Following the step-by-step guides for your operating system is sufficient to get a development environment running.
What is the difference between laravel new and composer create-project?
Both commands create a new project. composer create-project laravel/laravel is the universal method that works on any system with Composer. laravel new is a faster wrapper command that requires a prior global installation of the Laravel installer via composer global require laravel/installer.
I installed everything, but the artisan command isn’t working. Why?
The artisan command must be run from within your Laravel project’s root directory. Ensure your terminal is navigated to the folder that contains the artisan file. If it still fails, check your PHP version and that no PHP extensions are missing.
Install Laravel Without the Hassle
Boost your development efficiency by managing and compiling assets with ease. Our experts can help you set up Laravel Mix perfectly.


