---
title: "How to Install Laravel"
description: "Here's a comprehensive guide on how to install the Laravel PHP framework on your server. Introduction Prerequisites Use Laravel Installer to Create a Project Create a New Laravel Project with..."
url: https://www.inmotionhosting.com/support/edu/laravel/how-to-install-laravel/
date: 2023-10-02
modified: 2024-05-10
author: "Derrell"
image: https://www.inmotionhosting.com/support/wp-content/uploads/2023/09/install-laravel.png
categories: ["Laravel"]
type: post
lang: en
---

# How to Install Laravel

![](https://www.inmotionhosting.com/support/wp-content/uploads/2023/09/install-laravel-1024x537.png)

Here's a comprehensive guide on how to install the [Laravel PHP framework](https://laravel.com) on your server.

- [Introduction](#Introduction)
- [Prerequisites](#prerequisites)
- [Use Laravel Installer to Create a Project](#laravel-installer)
- [Create a New Laravel Project with Composer](#new-laravel-project)
- [Conclusion](#conclusion)

## Introduction

As a favorite amongst PHP developers, Laravel boasts of an elegant syntax and streamlined development processes. Here, we'll guide you through the installation process so that you can start developing directly on your server.

Choose from our [Laravel Hosting](https://www.inmotionhosting.com/laravel-hosting), [VPS Hosting](https://www.inmotionhosting.com/vps-hosting), or [Dedicated Servers](https://www.inmotionhosting.com/dedicated-servers) to host your Laravel applications and websites today!

## Prerequisites

Before you dive into Laravel, make sure your server meets the following requirements:

- PHP version of 8.1 or higher. wp:list /wp:list
  - PHP extensions required: BCMath, Ctype, cURL, DOM, Fileinfo, JSON, Mbstring, OpenSSL, PCRE, PDO, Tokenizer, and XML.
- A web server such as [Apache](https://httpd.apache.org) or [Nginx](https://www.nginx.com).
- A database management system such as [MySQL](https://www.mysql.com), [MariaDB](https://mariadb.com), or [PostgreSQL](https://www.postgresql.org).
- [Composer](https://getcomposer.org) installed. Laravel uses Composer as a package manager to manage its dependencies.

We're going to help you check that you have all prerequisites installed. If you don't, we'll link you to documentation to help install them, ensuring a smooth Laravel installation process.

### PHP Version

Check to see if you have the required PHP 8.1 (or above) installed as the system default for your server by running `php -v` which should output the version.

```
PHP 8.1.23 (cli) (built: Sep 13 2023 02:57:29) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.23, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.23, Copyright (c), by Zend Technologies
```

If you need to install a newer PHP version and/or PHP extensions, for servers with cPanel you can [Upgrade PHP using EasyApache 4](https://www.inmotionhosting.com/support/edu/easyapache/upgrade-php-easyapache/).

### Web Server

To check to see if you are running a web server and the version, in your server's terminal run `httpd -v` for Apache or `nginx -v` for Nginx.

```
$ httpd -v
Server version: Apache/2.4.57 (cPanel)
Server built:   Sep 12 2023 20:22:59
```

```
$ nginx -v
nginx version: nginx/1.23.4 (imh_ngx_20230406)
```

If you don't see a web server installed, please visit our [Apache Tutorials](https://www.inmotionhosting.com/support/server/apache/) and [Nginx Tutorials](https://www.inmotionhosting.com/support/server/nginx/) for installation steps.

### Composer

To check to see if Composer is installed on your server by running `composer -V` in your server's terminal which should produce output similar to this

```
Composer version 2.4.4 2022-10-27 14:39:29
```

If `Composer` is not installed on your server, you can install it locally for your project or globally by visiting the [Composer Installation Documentation](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos).

## Use Laravel Installer to Create a Project

The Laravel Installer is a tool that provides a streamlined method for creating a fresh Laravel project. It's a convenient alternative to the traditional method of [installing Laravel through Composer](#new-laravel-project). By using the Laravel Installer, users can swiftly initialize a new Laravel application by executing a simple command in their terminal or command prompt. This simplifies the process, making it more efficient and user-friendly, especially for those who frequently work with Laravel projects. The installer downloads the latest version of Laravel, sets up all the directories and permissions, and makes the application ready for development.

If you prefer to create a Laravel project with the default configuration that you can modify later, you can quickly [Create a New Laravel Project with Composer](#new-laravel-project).

As the user for the account that you want to install Laravel, use Composer to install the Laravel Installer.

```
composer global require laravel/installer --update-with-all-dependencies
```

You want to make sure that you add `$HOME/.config/composer/vendor/bin` to your `PATH` so the Laravel executable is found when you run the Laravel command to create a new project.

For Bash, you can automatically add this to your `$HOME/.bashrc` file by typing the following

```
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
```

You can either log out and back in or run `source ~/.bashrc` for the changes to take effect

### Create a New Laravel Project

Now that you successfully set up the Laravel Installer, you can use the `laravel` command to create a new Laravel project. Navigate to the document root of the target domain and start the Laravel installer with `your_project_name` being a name of your choice for the project.

```
laravel new your_project_name
```

This will create the directory `your_project_name` and start the installer.

```
_                               _
  | |                             | |
  | |     __ _ _ __ __ ___   _____| |
  | |    / _` | '__/ _` \ \ / / _ \ |
  | |___| (_| | | | (_| |\ V /  __/ |
  |______\__,_|_|  \__,_| \_/ \___|_|


 ┌ Would you like to install a starter kit? ────────────────────┐
 │ › ● No starter kit                                           │
 │   ○ Laravel Breeze                                           │
 │   ○ Laravel Jetstream                                        │
 └──────────────────────────────────────────────────────────────┘
```

[Laravel's documentation](https://laravel.com/docs/10.x/starter-kits) provides detailed information on Starter Kits.

## Create a New Laravel Project with Composer

For a simpler and quicker alternative to using the[ Laravel Installer](#laravel-installer), you can use the `composer` command to create a new project. Navigate to the empty document root of the domain you want Laravel installed and initiate your project.

```
composer create-project laravel/laravel .
```

Once that completes, you should see the default Laravel files in the current working directory.

If you see an error stating that the directory is not empty

```
Project directory "/home/producthub/laraveltest.product-content-hub.com/lartest/test-project/test-project/." is not empty.
```

Make sure there aren't any hidden files that may be blocking the installation by running `ls -lah` to list all files (including hidden files) and directories within your current working directory.

## Viewing your New Laravel Installation

To be able to see the default Laravel installation page by visiting your domain, add the following to your `.htaccess` file in your domain's document root to make sure that your website is being served from Laravel's `/public` directory.

```

RewriteEngine On
RewriteRule ^(.*)$ public/$1 

```

If you installed Laravel into a subdirectory using the Laravel Installer, you can either move the installed files and directories to the domain's document root or you can add the following to your .htaccess file in your domain's document root (replacing `your_project_name` with the actual directory that Laravel was installed):

```

RewriteEngine On
RewriteRule ^(.*)$ your_project_name/public/$1 

```

You should now be able to view your Laravel installation by visiting your domain in your web browser.

![](https://www.inmotionhosting.com/support/wp-content/uploads/2023/09/image-1024x550.png)

## Conclusion

Now that you have installed Laravel and confirmed that it was successful, you can begin building your project! The `.env` file contains different [environment configuration](https://www.inmotionhosting.com/support/edu/laravel/understanding-the-laravel-env-file/) values such as database information and application URL that can be edited to fit the needs of your new project.
