We need some prerequisite before installing Laravel. Following requirement for server needed prior to installing Laravel. If you did not install the LAMP yet than install it first.
- PHP >= 7.1.3
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- BCMath PHP Extension
Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.
Once you installed Composer we are ready to install Laravel using Create-Project command. See Below code:
composer create-project --prefer-dist laravel/laravel YOURPROJECTNAME
Give Permission to Directory
After installing Laravel, we need to give write permission to storage and bootstrap/cache.
chmod -R 777 storage chmod -R 777 bootstrap/cache
Create environment File
Now our next step is to create an environment file for our application. Its very simple just copy .env.example (It’s already available in the root of our application files) to .env
cp .env.example .env
Generate Application Key
Last we need to generate the key for our application using the following code.
php artisan key:generate
It will generate a 32 character long string and assign to APP_KEY in the .env file. That’s it now we are ready to run our application.
Run the development Server
We are going to use PHP’s built-in development server for our application.
php artisan serve
This command will start a development server at http://127.0.0.1:8000. You can also change this port like below.
php artisan serve --port=8001