Laravel is an open source widely used PHP Framework for web applications. It’s syntax, working principle is so much expressive and elegant. Development of web application in Laravel framework now a days very popular among developers.
Laravel is packed of strong features and/or module for the development environment.
Laravel first version was released at June 2011. Now, it’s Laravel 8 (8th Sept 2020). Every version of this framework brings lots of new features which reduces development effort and develop an application too much faster.
Learn More –
- API Authentication using Laravel 8 Sanctum Tutorial
- Bar Chart Integration with Laravel 8 Tutorial Example
- Barcode Generator in Laravel 8 Tutorial
- Bootstrap Growl jQuery Notification Plugin to Laravel 8
Inside this article we will see Laravel 8 Installation. This step by step guide helps you to understand about the Laravel system and application needed requirements before digging into application development.
Let’s get started.
System Requirements – Laravel 8 Framework
While working and/or developing any application in laravel 8 version. We should have some PHP and system configuration need.
Before going to Laravel 8 Installation, we have to make sure of these following configuration.
- PHP & Server Configuration
- Composer Installation
PHP & It’s Exentions
Here are some needed PHP and it’s extension needed configuration that we must need before go with Laravel 8.
- PHP Version >= 7.3
- BCMath PHP Extension
- Ctype PHP Extension
- Fileinfo PHP extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Server Requirement
You should have Apache or Nginx a web server in your system. According to your available operating system you need to install Either WAMP (Windows bases OS), XAMPP (Cross platoform OS), LAMP (Linux bases OS) servers to run PHP applications.
How to Install PHP >= 7.3?
Here, inside this article topic we will see about PHP >=7.3 installation. After installing we need to install it’s need extensions as well. I am having Ubuntu OS 18.04.
I am writing the step by step command which you need to execute in terminal for installation.
Need to check Ubuntu having latest packages and it’s modules, run following commands –
$ sudo apt update
$ sudo apt upgrade
Above command will install or updates system dependencies upto mark.
We need to Add PPA for PHP, run these following commands.
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
Once PPA has been installed, now we can install PHP >=7.3 version in any of web server either on Nginx or Apache. Here we will discuss both.
PHP >= 7.3 FPM Installation in Nginx
To Install PHP v7.3 we need to run this given command.
$ sudo apt install php7.3-fpm
To install PHP v7.4 we need to run this command, only to change 7.3 to 7.4
$ sudo apt install php7.4-fpm
Install PHP >= 7.3 for Apache
For Apache installation, run this command to your terminal.
$ sudo apt install php7.3
And for PHP 7.4 we need to execute this.
$ sudo apt install php7.4
Successfully, we have installed PHP >= 7.3 version to system. Next we need to verify that.
Verification of PHP Installation
We have two options available to check PHP installation. These are the following ways to verify.
- Using Command Line
- Using PHP function
Verify by Command Line
Open terminal and type command, this command is for Apache.
$ php -v
Output
PHP 7.3.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 9 2020 06:46:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
To verify for Nginx
$ php-fpm7.3 -v
Verify by PHP Function
You need to go at your localhost. Create a file with a name and with .php extension. Like I have created a file at root named as info.php
<?php phpinfo();
We need to run this file at browser. Open browser and type URL – http://localhost/info.php
Installation of PHP Extensions & Restart
Run this given command to install PHP v7.3 extensions.
We can also run each command from this syntax one by one. But we are going to run install all modules or extensions at once.
$ sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl -y $ sudo apt-get install libapache2-mod-php7.3
Switch PHP version
If your system has any old version of PHP say 7.2. But now, you have installed the latest version. You need to switch your PHP version from 7.2 to 7.3. To switch version
Disable old PHP version & then Enable new PHP version
To disable old version, this command will help you.
$ sudo a2dismod php7.2
Enable new PHP version say 7.3
$ sudo a2enmod php7.3
Next, all we need to restart application web server. This restart makes all changes to their correct settings.
Restarting Apache Server
$ sudo service apache2 restart
Restarting Nginx Server
$ sudo systemctl restart nginx
Composer Installation
We need to set firstly system dependencies and it’s packages at their latest version. Again same what we did above, needs to run this command.
$ sudo apt update
Next we are going to run command using cURL, you need to make sure you should curl extension enabled. Otherwise run this command to install.
$ sudo apt install curl php-cli php-mbstring git unzip
Back to home directory
$ cd ~
Download composer installer
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Generating hash value for composer installer
$ HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
Verifying hash key and installer
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installing composer
$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
If suppose, you have any permission issue with composer file, assign by this
$ sudo chmod +x /usr/local/bin/composer
Successfully, by following command Composer will be installed successfully. To test composer, back to terminal and type command
$ composer
Laravel 8 Installation
As from the following above steps, we have successfully installed PHP, it’s extension and composer.
Now, we can install Laravel 8 to system. Laravel Installation can be done in two ways.
- Laravel Installer
- By using composer
Laravel Installer
To install Laravel via Laravel installer, we need to install it’s installer first. We need to make use of composer for that.
$ composer global require laravel/installer
This command will install laravel installer at system. This installation is at global scope, so you type command from any directory at terminal. To verify type the given command –
$ laravel
This command will open a command palette of Laravel Installer.
To create ad install laravel project in system,
$ laravel new blog
With the name of blog a laravel project will be created at your specified path.
By using composer
Alternatively, we can also install Laravel by Composer command create-project. Here is the complete command to create a laravel project-
composer create-project --prefer-dist laravel/laravel blog
After following these steps we can install a Laravel 8 applicaton into system. To start the development server of Laravel –
$ php artisan serve
This command outputs –
Starting Laravel development server: http://127.0.0.1:8000
We hope this article helped you to learn Laravel 8 Installation in system in a very detailed way.
Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.
If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.