Web developer & teacher @saaslit
How to install Laravel 11 on Linux
Laravel 11 is the new version of Laravel - at the time of writing. Let's see how to install it on a Ubuntu-based machine.
Prerequisite
By default, Laravel v11 tries to connect to a sqlite database, so ensure it is properly installed with
sudo apt update
sudo apt install sqlite3
sqlite3 --version
Add default adapter for PHP
sudo apt install php-sqlite3
And default php driver with
sudo apt-get install php-pgsql
Install PHP8.3
Laravel 11 requires PHP 8.2 or 8.3, so let's install the latest version
It should work the same way if you installed MySql and not PostGre
1. Run system updates
sudo apt update && apt upgrade -y
2. Add Ondrej repository
The current maintainer of PHP is Ondrej Sury. It sounds odds that the package of such a language doesn't belong to an organisation, but here you can add it safely :
sudo add-apt-repository ppa:ondrej/php
Update all repositories once again with
sudo apt update
3. Add dependencies
Laravel will be buggy if you don't install PHP base modules
sudo apt-get install -y php8.3-cli php8.3-sqlite3 php8.3-common php8.3-fpm php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath
Now check PHP version with
php --version
# PHP 8.3.4
Install composer
composer
is a tool to build new laravel application.
Follow first paragraph of getcomposer
Ensure it is properly working on your machine by typing
composer --version
# Composer version 2.7.2 2024-03-11 17:12:18
Create a default Laravel 11 application
composer create-project laravel/laravel=11 MyApp
Installation will last a few second, it should end up with migrations, like this
# long previous logs...
INFO Running migrations.
0001_01_01_000000_create_users_table .......................... 31.91ms DONE
0001_01_01_000001_create_cache_table .......................... 18.81ms DONE
0001_01_01_000002_create_jobs_table ........................... 24.48ms DONE
Run the application
cd MyApp
php artisan serve
Open browser at http://127.0.0.1:8000, and ta-da!