Laravel Installation Installation


Laravel applications are installed and managed with Composer, a popular PHP dependency manager. There are two ways to create a new Laravel application.

Via Composer

$ composer create-project laravel/laravel [foldername]


$ composer create-project --prefer-dist laravel/laravel [foldername]

Replace [foldername] with the name of the directory you want your new Laravel application installed to. It must not exist before installation. You may also need to add the Composer executable to your system path.

If want to create a Laravel project using a specific version of the framework, you can provide a version pattern, otherwise your project will use the latest available version.

If you wanted to create a project in Laravel 5.2 for example, you'd run:

$ composer create-project --prefer-dist laravel/laravel 5.2.*

Why --prefer-dist

There are two ways of downloading a package: source and dist. For stable versions Composer will use the dist by default. The source is a version control repository. If --prefer-source is enabled, Composer will install from source if there is one.

--prefer-dist is the opposite of --prefer-source, and tells Composer to install from dist if possible. This can speed up installs substantially on build servers and in other use cases where you typically do not run vendor updates. It also allows avoiding problems with Git if you do not have a proper setup.

Via the Laravel installer

Laravel provides a helpful command line utility to quickly create Laravel applications. First, install the installer:

$ composer global require laravel/installer

You have to make sure that the Composer binaries folder is within your $PATH variable to execute the Laravel installer.

First, look if it already is in your $PATH variable

echo $PATH

If everything is correct, the output should contain something like this:


If not, edit your .bashrc or, if your using ZSH, your .zshrc so it contains the path to your Composer vendor directory.

Once installed, this command will create a fresh Laravel installation in the directory you specify.

laravel new [foldername]

You can also use . (a dot) in place of [foldername] to create the project in the current working directory without making a sub-directory.

Running the application

Laravel comes bundled with a PHP-based web server which can be started by running

$ php artisan serve

By default, the HTTP server will use port 8000, but if the port is already in use or if you want to run multiple Laravel applications at once, you can use the --port flag to specify a different port:

$ php artisan serve --port=8080

The HTTP server will use localhost as the default domain for running the application, but you can use the --host flag to specify a different address:

$ php artisan serve --host= --port=8080

Using a different server

If you prefer to use a different web server software, some configuration files are provided for you inside the public directory of your project; .htaccess for Apache and web.config for ASP.NET. For other software such as NGINX, you can convert the Apache configurations using various online tools.

The framework needs the web server user to have write permissions on the following directories:

  • /storage
  • /bootstrap/cache

On *nix operating systems this can be achieved by

chown -R www-data:www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache

(where www-data is the name and group of the web server user)

The web server of your choice should be configured to serve content from your project's /public directory, which is usually done by setting it as the document root. The rest of your project should not be accessible through your web server.

If you set everything up properly, navigating to your website's URL should display the default landing page of Laravel.