Web frameworks · Intermediate · 20 min
How to Install Laravel 13 on Ubuntu 26.04 with PHP 8.5
By Padding · Updated 15 Nov 2026
Ubuntu 26.04.1 LTS · Laravel 13 · PHP 8.5
You will install PHP 8.5 from Ubuntu's own repositories and Composer from its official installer with a checksum check, create a Laravel 13 project, add a route, controller, view and test, and run the app with the built-in development server.
On this page
Laravel is a PHP web framework with routing, templates, a database layer, queues, authentication and a command-line tool called Artisan. It needs PHP and Composer, the PHP package manager, and nothing else to start. A new project uses SQLite for its database by default, so you do not need a database server for this tutorial.
Ubuntu 26.04 ships PHP 8.5 in its normal repositories, so there is no third-party package source to add. You get security updates for PHP through apt like everything else. Composer is installed with its official installer, after a check that the file matches the hash that the Composer project publishes. This tutorial gets Laravel running and shows its main pieces. It stops short of serving it to the internet. That is covered by the follow-up tutorial on deploying Laravel with Nginx and PHP-FPM, linked at the end.
Step 1 · Install PHP 8.5 and its extensions
Laravel needs several PHP extensions, which Ubuntu packages separately. php8.5-cli is PHP for the command line, and the rest are the extensions the framework and Composer use. unzip and git let Composer download packages quickly, and curl fetches the installer:
sudo apt update
sudo apt install -y php8.5-cli php8.5-mbstring php8.5-xml php8.5-curl php8.5-zip php8.5-sqlite3 php8.5-bcmath php8.5-intl unzip git curl ca-certificates
php -vCheck it worked
php -v starts with PHP 8.5. and a patch number, and (cli). Confirm the extensions Laravel requires are loaded:
php -m | grep -E -x 'mbstring|curl|xml|tokenizer|pdo_sqlite|openssl|ctype|fileinfo' | wc -lThe output is 8, one for each required extension.
Step 2 · Install Composer with a checksum check
The Composer installer is a PHP script. The project publishes the SHA-384 hash of the current installer, and the safe way to install is to download both and compare them before you run anything:
cd "$(mktemp -d)"
EXPECTED="$(curl -fsSL https://composer.github.io/installer.sig)"
curl -fsSL https://getcomposer.org/installer -o composer-setup.php
ACTUAL="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED" = "$ACTUAL" ]; then echo "Installer verified"; else echo "Installer corrupt"; rm composer-setup.php; false; fiThe output must be Installer verified. If it says Installer corrupt, the script has deleted the file. Do not run it, and try again later. Install Composer system-wide, then remove the installer:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
rm composer-setup.php
composer --versionComposer installed this way is not updated by apt. To update it later, run sudo composer self-update.
Check it worked
composer --version prints Composer version 2. and a release number with a date.
Ubuntu also packages Composer as composer, in its universe repository, and apt would keep that copy updated. It trails the official release, and Laravel's tooling expects a recent Composer, so this tutorial uses the official installer.
Step 3 · Create the project
composer create-project downloads the Laravel starter project and its dependencies into a new folder. The version constraint ^13.0 keeps you on Laravel 13:
cd ~
composer create-project laravel/laravel:^13.0 notes-app --no-interaction
cd notes-app
php artisan --versionThe starter project's setup scripts run at the end: they create a .env file with a fresh APP_KEY, create an empty SQLite database file, and run the first migrations. A migration is a script that changes the database structure.
Check it worked
php artisan --version prints Laravel Framework 13. and a release number. The folder holds the pieces you will use:
lsThe listing includes app for your PHP code, routes for URL definitions, resources for views, database, config, public, tests and artisan. Only public is ever meant to be reachable from the web. Everything else, including .env, stays outside the web root.
Troubleshooting
If Composer says a PHP extension is missing, it names it. Install the matching php8.5-<name> package and run the command again. If a download fails with a timeout, run the same command again, because Composer resumes from its cache. Composer's warning about running as root appears if you installed as the root user, so use your own account.
Step 4 · Look at the environment file
Laravel reads its settings from .env, a file in the project root. Look at the lines that matter now, without printing the secret key:
grep -E '^(APP_NAME|APP_ENV|APP_DEBUG|APP_URL|DB_CONNECTION)=' .env
grep -c '^APP_KEY=base64:' .envAPP_KEY is a random secret that signs and encrypts cookies and sessions. Treat it like a password: it is private to this install, and it must not be committed, which is why .env is listed in the project's .gitignore. The second command above prints 1, which tells you the key exists without showing it. APP_DEBUG=true and APP_ENV=local are settings for development. A server must use APP_ENV=production and APP_DEBUG=false, because debug pages expose code and configuration.
On a machine that other people log in to, make the file readable by you alone:
chmod 600 .env
ls -l .envThe listing starts with -rw-------.
Step 5 · Run the development server
Artisan includes a small web server for development. Start it in the foreground in one terminal and keep it running:
php artisan serveIt prints Server running on [http://127.0.0.1:8000]. In a second terminal, request the home page:
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/
curl -s http://127.0.0.1:8000/ | grep -o '<title>[^<]*</title>'Check it worked
The first command prints 200, and the second prints <title>Laravel</title>. Open http://127.0.0.1:8000 in a browser to see the Laravel welcome page. The development server listens only on your own machine. If you work on a remote server, forward the port over SSH rather than opening it to the network: ssh -L 8000:127.0.0.1:8000 you@your-server, run from your own computer.
Step 6 · Add a route, a controller and a view
A route connects a URL to code. Start with a controller, a class that handles requests for one part of the app. Artisan creates the file:
php artisan make:controller NoteControllerIt creates app/Http/Controllers/NoteController.php. Replace its content with an action that passes a list to a view:
cat > app/Http/Controllers/NoteController.php <<'PHP'
<?php
namespace App\Http\Controllers;
use Illuminate\View\View;
class NoteController extends Controller
{
public function index(): View
{
$notes = [
'Install PHP 8.5',
'Install Composer',
'Create <b>a project</b>',
];
return view('notes', ['notes' => $notes]);
}
}
PHPThe view is a Blade template, which is HTML with a few slots for values. Create resources/views/notes.blade.php:
cat > resources/views/notes.blade.php <<'BLADE'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Notes</title>
</head>
<body>
<h1>Notes</h1>
<ul>
@foreach ($notes as $note)
<li>{{ $note }}</li>
@endforeach
</ul>
</body>
</html>
BLADENow add the route to the end of routes/web.php. Writing the class name in full avoids having to add an import line near the top of the file:
cat >> routes/web.php <<'PHP'
Route::get('/notes', [\App\Http\Controllers\NoteController::class, 'index']);
PHP
php artisan route:list --path=notescurl -s http://127.0.0.1:8000/notesIf the first request after saving the files answers with a 404 Not Found page, wait a few seconds and run the curl command again, since the server can take a moment to notice changed files.
Check it worked
route:list prints a table with one row, GET|HEAD notes pointing at App\Http\Controllers\NoteController@index. The curl command prints the page with three list items. The third reads Create <b>a project</b>: the double braces {{ }} in Blade escape what they print, so markup in your data cannot become markup on the page. Use {!! !!} only for HTML that you have written and trust.
Step 7 · Write a test
Laravel's starter project is set up for tests, which run with php artisan test. Add a feature test that requests the page the way a browser would, in memory, with no server:
cat > tests/Feature/NotesTest.php <<'PHP'
<?php
namespace Tests\Feature;
use Tests\TestCase;
class NotesTest extends TestCase
{
public function test_notes_page_lists_notes(): void
{
$response = $this->get('/notes');
$response->assertOk();
$response->assertSee('Install Composer');
}
public function test_notes_are_escaped(): void
{
$response = $this->get('/notes');
$response->assertDontSee('<b>a project</b>', false);
}
}
PHP
php artisan testThe false argument tells assertDontSee not to escape the string it searches for, so the test looks for the raw tag in the output.
Check it worked
The test run lists each test with PASS, including the two in NotesTest and the two starter tests, and ends with a line like Tests: 4 passed (5 assertions) and a duration.
Step 8 · Stop the server and clean up
Press Ctrl+C in the terminal that runs php artisan serve. To remove the demo project, delete its folder:
cd ~
rm -rf ~/notes-appPHP and Composer stay installed. To remove Composer as well, run sudo rm /usr/local/bin/composer.
Next steps
- Put the app on the internet behind a real web server: deploy a Laravel app with Nginx and PHP-FPM.
- Add a database server when SQLite is no longer enough: install PostgreSQL 18 on Ubuntu 26.04 or MySQL 9.7 LTS.
- The Laravel documentation at laravel.com/docs covers routing, Eloquent, queues and authentication in depth.
Related tutorials
- How to Deploy a Laravel App with Nginx and PHP-FPMYou will serve a Laravel 13 app on Ubuntu 26.04 with Nginx 1.30 passing PHP requests to a dedicated PHP-FPM 8.5 pool over a Unix socket, with APP_DEBUG off, a private .env file, code the app user cannot change, a production cache, and a repeatable deploy script.
- How to Deploy a Django App with Gunicorn and Nginx on Ubuntu 26.04You will run a Django 6.1 project on Ubuntu 26.04 with DEBUG off, a secret key kept in a private file, Gunicorn started by a systemd socket and service as an unprivileged user, and Nginx serving static files and passing everything else to the app.
- How to Create Your First Django 6 AppYou will create a Django 6.1 project with uv on Python 3.15, build a small bookmarks app with a database model, an admin screen, a page and a test, and see how the pieces connect.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials