This tutorial shows step-by-step guide to install Laravel. Here, I will show two ways for installation. One is installing directly by composer create-project
command and the other is by cloning or downloading Laravel from GitHub and then running the composer install
command.
1) Method 1
- Go to your web server root
- In Ubuntu, it’s /var/www/.
- In Windows, if you install Wampp on C: drive then the server root is C://wamp/www/, for Xampp, it’s C://xampp/htdocs/
- Run the following command in terminal/command-prompt:
composer create-project laravel/laravel name-of-your-project
- This will create a directory with
name-of-your-project
and install Laravel files in it - Then, you can simply browse
http://localhost/name-of-your-project/public
to access Laravel
2) Method 2
- Go to Laravel Github
- Clone or Download it to your web server root
- Suppose, you kept the cloned/downloaded files in ‘laravel’ directory
- Go to your Laravel directory (in Ubuntu Linux, it will be /var/www/laravel)
- Run the following command
composer install
- This will install the required dependencies to run Laravel. It will take some time to install all the dependencies.
- Now, you should be able to access Laravel properly without any error, e.g.
http://localhost/laravel/public
Note 1:
If you are on Linux then you should also set write permission to bootstrap/cache
and storage
directories.
Here’s the command to do so:
sudo chmod -R 777 bootstrap/cache storage
Note 2:
After this, you should be able to browser your Laravel site. If you get ‘No encrypter found’ error then it means that your site’s encryption key has not been generated yet. To generate the encryption key for your application, you need to follow the steps below:
- Go to your Laravel directory
- Rename
.env.example
to.env
- Now, open terminal or command-prompt
- Run the following command on terminal:
php artisan key:generate
- You will see the message on terminaly saying application key set successfully.
- This will update
.env
file present in your laravel root folder. In that file, it will set the value ofAPP_KEY
. - This will solve this error and now you should be able to browse the site properly.
Hope this helps. Thanks.