First step toward learning laravel is to know how we can first install laravel framework locally. In this tutorial we will cover how we can install laravel on following operating systems:
- MacOS
- Linux
- Windows
How to install laravel 9 framwork on Mac OS?
In order to install laravel 9 framework onto your mac os you need to have following dependencies:
- curl
- docker
- docker desktop
Curl helps you access the remote script while docker assists you to run your different services in docker containers. If you do not know anything about docker don't worry follow my tutorials on Docker.
Create sample laravel 9 project locally by running following curl script. You can replace example-app from the following command to whatever name of your project.
# go to your local directory where you want to add this new project cd ~/workspace # now create a new laravel 9 project curl -s "https://laravel.build/example-app" | bash
Once it creates the project locally you can run laravel 9 using sail. You might be wondering what is sail and why do I need that? Well sail is just a command line utility that helps you manage dockerized laravel project.
If you do not know how it works I have seperate tutorials for you to learn about sail in depth:
For now, just run following command to run your laravel 9 project locally via sail:
# go to your new laravel project root directory cd example-app # run docker containers using laravel sail ./vendor/bin/sail up
Once you run above command it will first build images for each service you required for your laravel project this process takes bit of a time for the first time.
Once container images are build next time you run above command it will not take long. Once the Docker containers have been started, you can access the application in your web browser at: http://localhost.
If you are beginner you might be overwhelmed by this process however you might need to remember only following two commands in the beginning.
# to start the containers ./vendor/bin/sail up # to stop the containers ./vendor/bin/sail down
How to install Laravel 9 on windows?
In order to run laravel 9 project locally on windows machine you need to have following dependencies installed aleady:
- Docker Desktop
- Linux 2 (WSL2) installed and enabled
Open terminal for your WSL2 Linux opeating system. Run following command to create laravel project locally.
If you want to name your laravel 9 project differently remove example-app from the following command to whatever new name of your laravel project.
curl -s https://laravel.build/example-app | bash
Now, run following command to start the laravel application using sail.
# go to your project root directory cd example-app #start the docker containers ./vendor/bin/sail up
Once the docker containers are built and run you can access your new laravel project in your web browser at: http://localhost.
If you do not know how sail works I have seperate tutorials for you to learn about sail in depth:
How to install laravel 9 on Linux/Ubuntu?
Installing laravel 9 on linux or ubuntu is very easy. You should have following dependencies already installed before you begin installation:
- docker
- curl
First run following command that creates a local laravel project directory.
You can change example-app from the following command to whatever new name of your laravel project that you want to give it locally.
curl -s https://laravel.build/example-app | bash
Laravel runs its framework in docker container using Laravel Sail command line utility.
If you do not know how docker works do not worry about this at this point. You can learn about Docker by following my tutorials on docker:
Following command will first build the docker container image and then run the container.
# go to your project root directory cd example-app #start the docker containers ./vendor/bin/sail up
Once the docker containers are built and run you can access your new laravel project in your web browser at: http://localhost.
If you do not know how sail works I have seperate tutorials for you to learn about sail in depth:
Install laravel 9 without docker?
If you are beginners and just want to learn laravel 9 running laravel using docker and sail might overwhelm you. You can install and run laravel without using docker environment,
First of all you need to have composer installed on your operating system before you create a new laravel project locally. If you do not know how to install composer follow the link below to install composer locally.
Once you have composer installed run following command to create local laravel project:
# create a new laravel project # replace example-app with name of your choice composer create-project laravel/laravel example-app # now go to new directory created cd example-app # run laravel locally php artisan serve
Your new laravel project will be available in your web browser at: http://localhost.