How To Install Laravel 6 on Windows and Linux
Recently Laravel 6 has been released which is the latest LTS release. In this post, we will install Laravel 6 on both Windows and Linux based operating systems.
Laravel 6 is a long term release and it will provide the security fixing and bugs fixing for longer period. From Laravel 6 onward, SemVer (Semantic Versioning) will be used for the future release which means the next LTS release of Laravel framework will be Laravel 7.
You can check out this post Laravel 6 – A Look at What’s New Coming to learn more about the new changes introduced in the Laravel 6 release.
Requirements to Install Laravel
Before moving to the Laravel installation, we have to make sure that our machine fulfills all the requirements of the Laravel framework. Before proceeding make sure machine meets the following system requirements.
- A webserver Apache or Nginx
- PHP >= 7.1.3
- OpenSSL PHP Extension
- PDO PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- MBString PHP Extension
- Tokernizer PHP Extension
- XML PHP Extension
- BCMAth PHP Extension
What is Composer?
Composer is a dependency management tool that allows us to manage and control the dependencies of our PHP based applications. Composer is an Open Source application and FREE to the user.
Download and Install Composer in Windows
Before installing Composer, please make sure you have the PHP and MySQL installed on the computer and it’s working. To check this open the command line terminal (Git Bash or Windows Command Terminal) and run the below command.
If the PHP is installed and running properly, then you will have output something like below.
λ php -v PHP 7.2.14 (cli) (built: Jan 9 2019 22:23:26) ( ZTS MSVC15 (Visual C++ 2017) x64 ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Next, we will download the latest version of Composer for Windows from the official website. On the Composer’s website’s Download section you will get the link to download the Composer-Setup.exe file.
The file size of this installation file is very small, once you have downloaded the file head over to the next step.
You will need to run the Composer’s installation file as any Adminstrator if you are on a shared network. Right-click on the file and choose Run as Adminstrator.
You will have the installation window open like below simply, click on Next.
Next, the installation will automatically locate the PHP installed on your computer, simply press Next.
Next, it will ask you for any proxy settings, simply press Next.
Now, the composer is ready to install, click on Install button and composer will be installed on your computer.
When the installation finish, open the command line terminal and run the
composer in it. If the composer has successfully installed, you will get the output as below.
Now, we’ll be moving to the process of Laravel download and install.
Creating New Laravel 6 Project using Composer
Open the command line terminal such as Git Bash or PowerShell of windows and run the below command to create a new Laravel 6 application.
composer create-project --prefer-dist laravel/laravel laravel-6-app
This process will take some time to install all dependencies and libraries. You will have output some like below.
Wait, until the process completes.
How to Run the Laravel Application
Once, the Laravel project is created you can start developing the next awesome application. Within the command line terminal run
cd laravel-6-app to move inside the project folder.
You can use any code editor such as Sublime, VS Code or PHPStorm. I recommend you to use the VS Code.
On command line terminal run the
code . command and it will open the current application folder inside the VS Code editor like below.
You can start the inbuilt PHP server to run the Laravel 6 application. Open the command line terminal and run the below command.
php artisan serve
The above command will start the Laravel development server. After that, open your browser and access the project by visiting the
localhost:8000 in your browser window.
Download and Install Composer on Linux
To install Composer on Linux, firstly you have to check if you have the PHP installed and it’s running. To check this run the
php -v command which will output the PHP version you are using on the Linux operating system.
Before installing Composer, you have to update the Linux libraries and packages. I am using the Ubuntu flavor of Linux. Run the below command to update the Linux system.
sudo apt-get update
Now, install the curl utility so that we can install the composer.
sudo apt-get install curl
Then, run the below command to install the composer.
curl -s https://getcomposer.org/installer | php
The above command will download the composer.phar package in the
/tmp directory. We want to run the composer globally, so we need to move this file to the
/usr/local/bin/ directory under the name composer.
So, run the below command to move the file.
sudo mv composer.phar /usr/local/bin/composer
Now you can access composers from anywhere because it has been installed globally. Hence, check the composer in the terminal and type composer.
This will output the same result as we saw in the windows installation.
Install Laravel 6 on Ubuntu
Now, we will install the Laravel 6 in Ubuntu. First of all, we will need to navigate into the public html directory.
Actually, we are using Apache, so it should be installed the
/var/www/html directory. So for navigating into
/var/www/html please type the below command in the terminal.
Once, you are done with this, create a new project with Laravel installation by following the below command.
sudo composer create-project --prefer-dist laravel/laravel laravel-6-app
Running Laravel Application
Once you are done with the project creation, run the Laravel project using the following command.
php artisan serve
After that, open your browser and access the project by visiting the
localhost:8000 in your browser window.
In this, post we have installed Laravel 6 on Windows and Linux, in the next post I will show you how we can use the Laravel Homestead to create the whole development environment.
If you have any questions or suggestions, please let us know in the comments box below.