Installing Laravel

Installing Laravel

Laravel is a PHP framework so we need to start with a L(W)AMP server of some sort. We recommend PHP 7 but from PHP 5.6 will do.

Laravel is easiest to install with Composer.

Once Composer is installed according to their instructions, we can use it to install Laravel. There are different methods of installing Laravel but I prefer installing it as a global package on the system. To do this, on the command line type:

composer global require “laravel/installer”

and then press enter.

You’ll now need to add “$HOME/.composer/vendor/bin” to your system path so that your OS knows where to find Laravel. For Ubuntu we can do this in ~/.bashrc by adding the line:

export PATH=”$HOME/.composer/vendor/bin:$PATH”

This adds composer to your system path so that from the command line you can now type Laravel to see their help menus.

To create a fresh Laravel site all you need to do now is open a command line and cd to your web directory. So for me on Ubuntu:

cd /var/www/html

and then I run laravel like this:

laravel new my-cool-site

This will create the directory call my-cool-site with a new Laravel installation.

You should now use artisan to set the encryption key for the site you may get an error.

cd into your new directory:

cd my-cool-site

and type:

php artisan key:generate

You can now type:

php artisan serve

and copy the link it provides into a browser to see your new installation in action!

 

 

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *