How to Install Laravel on Ubuntu:Step-by-Step Guide

ho-to-install-laravel-in-ubuntu

On Ubuntu 24.04 or 26.04, the fastest current Laravel-recommended setup is to install PHP, Composer and the Laravel installer with: /bin/bash -c “$(curl -fsSL https://php.new/install/linux/8.5)”. Restart the terminal, install Node/NPM or Bun, run “laravel new example-app”, then “npm install && npm run build” and “composer run dev”. Laravel 13 requires PHP 8.3 or newer.

Ubuntu is a common environment for Laravel development and production hosting, but the installation path now depends on which Ubuntu release you are using. Laravel 13 requires PHP 8.3 or later, which means current Ubuntu 24.04 LTS and Ubuntu 26.04 LTS can support it with their standard PHP generations, while Ubuntu 22.04 LTS ships PHP 8.1 by default and needs a newer PHP installation before Laravel 13 can run.

This guide is written for Laravel developers, DevOps engineers, Linux users and development teams. It covers the recommended Laravel Linux installer, a manual Ubuntu package route, Composer, frontend tooling, database configuration, common permissions problems, Laravel Sail, verification and the difference between a local development setup and a production Ubuntu server.

Which Ubuntu Versions Work with Laravel 13?

Ubuntu releaseDefault PHPLaravel 13?What it means
Ubuntu 26.04 LTSPHP 8.5YesBest fit for a new 2026 environment if your wider stack supports it.
Ubuntu 24.04 LTSPHP 8.3YesStable LTS choice and directly compatible with Laravel 13 minimum requirements.
Ubuntu 22.04 LTSPHP 8.1Not with stock PHPInstall a supported PHP version separately or upgrade the OS before Laravel 13.

Laravel 13 officially requires PHP 8.3 or newer and supports PHP 8.3 through 8.5. Ubuntu package metadata lists PHP 8.3 as the default CLI version for Ubuntu 24.04 and PHP 8.5 for Ubuntu 26.04. Ubuntu 22.04 defaults to PHP 8.1, so a stock 22.04 PHP installation is not enough for Laravel 13.

Method 1: Recommended Laravel Installation on Ubuntu

Laravel currently provides a Linux installation script that installs PHP, Composer and the Laravel installer together. This is the simplest path for a local development machine when you want to follow Laravel defaults.

Step 1: Update the APT package index and install curl

sudo apt update
sudo apt install -y curl

The Laravel-provided installer is downloaded over HTTPS with curl. If curl is already installed, the second command simply confirms the dependency is available.

Step 2: Run Laravel’s official Linux installer

/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.5)"

At the time this guide was prepared, Laravel’s official documentation uses the Linux installer above with PHP 8.5. The script installs PHP, Composer and the Laravel installer. After it completes, restart the terminal session so updated PATH settings are loaded.

SECURITY PRACTICE

For company-managed development machines or production servers, review install scripts and change-control requirements before executing remote shell installers. Teams that require package-level control can use the manual Ubuntu method later in this guide.

Step 3: Verify PHP, Composer and Laravel

php -v
composer --version
laravel --version

For Laravel 13, php -v must report PHP 8.3 or later. If the laravel command is missing but Composer works, the usual issue is that Composer’s global bin directory is not in PATH.

Step 4: Install or verify Node.js and NPM

Laravel uses Vite for frontend assets. Install a current Node.js LTS release through the official Node.js instructions or your team’s version manager, then verify:

node -v
npm -v

Avoid assuming the Ubuntu repository version of Node is always suitable for every current frontend toolchain. Development teams usually benefit from a version manager so the project can pin a known Node version.

Step 5: Create the Laravel application

laravel new example-app
cd example-app

Replace example-app with your project name. The Laravel installer will guide you through application choices and create a new project directory.

Step 6: Install frontend dependencies and build assets

npm install && npm run build

A fresh Laravel project contains a package.json file for frontend tooling. npm install downloads those dependencies and npm run build generates production-ready assets once.

Step 7: Start the Laravel development environment

composer run dev

Laravel’s current development workflow starts the local application server, queue worker and Vite development server. Open http://localhost:8000 in a browser. If the Laravel page loads, the local installation is working.

Step 8: Verify the installed Laravel version

php artisan --version
php artisan about

Use php artisan –version to confirm the project framework version, not laravel –version, which reports the globally installed Laravel installer. For all version-checking methods, link readers to How to Check Laravel Version.

Configure the Database on Ubuntu

Fresh Laravel applications currently default to SQLite. Laravel creates database/database.sqlite and runs the initial migrations during project creation, so you can start without installing MySQL or PostgreSQL.

Using MySQL instead of SQLite

If your application needs MySQL, install the server and PHP MySQL driver, then create a database according to your organization’s security policy:

sudo apt update
sudo apt install -y mysql-server php-mysql

Update the Laravel .env file with the application’s database connection details:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=your_user
DB_PASSWORD=your_password

Then run:

php artisan migrate

Do not use a root database account in a real application. Create a dedicated database user with only the permissions the application requires.

Method 2: Manual Ubuntu Package Installation

Teams that manage standardized Linux environments may prefer APT packages instead of the Laravel-provided installer. On Ubuntu 24.04, the default PHP package is PHP 8.3; on Ubuntu 26.04 it is PHP 8.5. Both are within Laravel 13’s supported range.

Start with commonly required command-line packages and PHP extensions:

sudo apt update
sudo apt install -y php-cli php-curl php-mbstring php-xml php-zip php-bcmath unzip curl git

Then verify the version and extensions:

php -v
php -m

If your application uses MySQL or PostgreSQL, install the relevant PHP database driver such as php-mysql or php-pgsql. Laravel’s deployment documentation also lists required PHP extensions including Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO, Session, Tokenizer and XML.

For Composer, use the current verified installer instructions from getcomposer.org rather than copying an old checksum from a static tutorial. Once Composer is installed globally, install the Laravel CLI:

composer global require laravel/installer

Then continue with laravel new, npm install and composer run dev as shown in Method 1.

What If You Are Using Ubuntu 22.04?

Ubuntu 22.04 LTS ships PHP 8.1 as its default PHP generation, while Laravel 13 needs PHP 8.3 or newer. That means a plain sudo apt install php-cli on an unmodified 22.04 system will not satisfy Laravel 13.

For a new project, the cleanest options are usually to upgrade the operating system to a supported newer Ubuntu LTS release or use a controlled containerized environment. Existing production servers may instead install a newer PHP source according to the organization’s change policy, but that should be planned carefully because PHP-FPM, CLI, web-server configuration and extensions must all remain aligned.

BUSINESS/DEVOPS NOTE

If an existing Laravel production server is still on Ubuntu 22.04 with PHP 8.1, treat the Laravel 13 move as an environment upgrade project, not just a Composer update. Inventory PHP-FPM, Nginx/Apache, cron, queues, Redis, database drivers, CI/CD and monitoring before changing runtime versions.

Laravel Sail on Ubuntu: When Docker Makes Sense

Laravel Sail provides a Docker-based local development environment. It is useful when a team wants the same PHP, database and service versions on every developer machine instead of relying on host-level packages.

Sail currently supports PHP 8.3, 8.4 and 8.5 among other runtimes, and the current default runtime is PHP 8.5. On Ubuntu, Docker-based development can be especially convenient because Linux containers run natively without the extra virtualization layer used by some desktop operating systems.

Choose Sail when reproducibility matters more than keeping the host system minimal. Choose a native Ubuntu setup when developers want direct access to local PHP tooling and the team already standardizes package versions another way.

Ubuntu File Permissions: Avoid the Common Mistakes

Laravel must be able to write to storage and bootstrap/cache. In local development, the simplest setup is to keep the project owned by your normal user and avoid running Composer or NPM as root.

  • Do not solve local permission problems by repeatedly running sudo composer or sudo npm. That often creates root-owned project files and causes more permission issues later.
  • Keep the project directory owned by the developer account on a workstation.
  • On production, grant the web-server process the required write access to storage and bootstrap/cache according to your deployment model.
  • Never make the entire Laravel project world-writable.

Laravel’s deployment documentation explicitly requires the web-server process owner to be able to write to storage and bootstrap/cache.

Common Laravel Installation Errors on Ubuntu

ProblemRecommended check
curl: command not foundInstall curl with sudo apt install curl.
PHP version is below 8.3Use Ubuntu 24.04/26.04 defaults, Laravel’s Linux installer, a supported repository or a containerized runtime.
laravel: command not foundRestart the terminal and confirm Composer global bin is in PATH.
Composer reports missing ext-*Run php -m, identify the missing extension, install the appropriate Ubuntu PHP package and retry.
npm: command not foundInstall a current Node.js LTS release and verify node -v and npm -v.
Could not open input file: artisanChange into the Laravel project root – the directory containing artisan.
SQLSTATE connection refusedVerify the database server is running and the .env host, port, database, username and password are correct.
Permission denied in storageCorrect ownership/permissions for the project and writable Laravel directories; avoid blanket 777 permissions.
Port 8000 already in useStop the conflicting local service or run the development server on another port for troubleshooting.

Local Ubuntu Development vs Production Ubuntu Server

The commands in this guide create a development environment. A production Ubuntu server needs additional controls and should not simply run the local development process.

AreaProduction consideration
Web serverNginx, FrankenPHP or another production-capable application server; document the chosen architecture.
Document rootMust point to the Laravel public directory, never the project root.
PHP runtimeUse a supported PHP version with the extensions required by Laravel and the application.
EnvironmentAPP_ENV=production and APP_DEBUG=false; protect .env and secrets.
Permissionsstorage and bootstrap/cache writable by the appropriate process; source code otherwise restricted.
QueuesRun workers under a process supervisor or managed platform; monitor failures.
SchedulerConfigure the Laravel scheduler according to the application requirements.
Database / RedisUse production credentials, backups, monitoring and least-privilege access.
OptimizationRun production cache/optimization commands as part of deployment.
DeploymentUse repeatable CI/CD, backups, rollback planning and health checks.

Laravel’s official deployment documentation states that the web server must route requests through public/index.php and warns against serving the project root because sensitive files could be exposed.

How Much Does Laravel Setup on Ubuntu Cost?

Laravel itself is open source, so there is no framework licence fee for installing it on Ubuntu. For a developer workstation, the main cost is setup time and any infrastructure or tooling your team chooses.

For a business production environment, the cost is driven by architecture rather than the installation command. Variables include cloud or VPS infrastructure, database services, Redis, backups, CI/CD, monitoring, security hardening, load balancing, high availability, data migration and ongoing maintenance. Those requirements should be estimated as part of the overall Laravel application scope rather than priced as a generic “Laravel install”.

How Long Does Laravel Installation on Ubuntu Take?

The core commands are short, but a responsible estimate depends on the starting environment. A compatible Ubuntu 24.04 or 26.04 developer machine with working network access is much simpler than an older production server that also needs a PHP runtime upgrade, database migration, Nginx changes, queue supervision and rollback planning.

For teams, standardize the environment in documentation, Docker/Sail configuration or automation so setup time is repeatable and not dependent on one developer’s machine.

When Should a Team Get Professional Laravel / DevOps Help?

  • The server is on Ubuntu 22.04 or another environment with an unsupported PHP version.
  • The application handles customer data, payments or business-critical workflows.
  • You need Nginx/PHP-FPM, Redis, Horizon, queues, schedulers and SSL configured together.
  • The deployment requires AWS, Docker, CI/CD, staging and production parity.
  • The current application was inherited and server ownership or documentation is unclear.
  • A Laravel upgrade must be coordinated with an operating-system or PHP upgrade.
  • You need high availability, monitoring, backups or zero/low-downtime deployment.

Conclusion

For Ubuntu 24.04 and 26.04, installing Laravel 13 is straightforward because both releases provide a compatible PHP generation. The fastest current route is Laravel’s official Linux installer, followed by Node/NPM or Bun, laravel new, frontend dependency installation and composer run dev.

Ubuntu 22.04 requires more planning because its stock PHP 8.1 does not meet Laravel 13’s PHP 8.3 minimum. In that situation, treat the runtime change as part of the environment architecture rather than a one-line framework installation.

For a development workstation, focus on a clean, user-owned project and reproducible tooling. For production, focus on the public web root, supported PHP, file permissions, queues, database/Redis, secrets, monitoring, backups and controlled deployment.

Frequently Asked Questions

Can Laravel 13 run on Ubuntu 24.04?

Yes. Ubuntu 24.04 LTS uses PHP 8.3 as its default PHP generation, and Laravel 13 requires PHP 8.3 or newer. Install the required PHP extensions, Composer and Laravel tooling, then verify php -v before creating the application.

Can Laravel 13 run on Ubuntu 26.04?

Yes. Ubuntu 26.04 LTS uses PHP 8.5 as its default PHP generation, which is within Laravel 13's supported PHP 8.3-8.5 range. It is therefore a compatible base for a new Laravel 13 environment.

Why does Laravel 13 fail on Ubuntu 22.04?

Ubuntu 22.04 defaults to PHP 8.1, while Laravel 13 needs PHP 8.3 or newer. You need a supported newer PHP runtime, a containerized environment, or an operating-system upgrade before Laravel 13 can run.

What is the easiest way to install Laravel on Ubuntu?

The current Laravel documentation provides a Linux install command through php.new that installs PHP, Composer and the Laravel installer together. After restarting the terminal, create the project with laravel new and start the application with composer run dev.

Which PHP extensions does Laravel 13 need?

Laravel's deployment documentation lists Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO, Session, Tokenizer and XML in addition to PHP 8.3 or newer. Database-specific applications may also need drivers such as php-mysql or php-pgsql.

Do I need MySQL to install Laravel on Ubuntu?

No. Fresh Laravel applications default to SQLite, so you can create and run an application without installing MySQL. Use MySQL or PostgreSQL when the application requirements call for them, then update .env and run migrations.