How to install Laravel on Ubuntu 22.04

The PHP framework Laravel provides an extensive collection of libraries and components for PHP development. Here you can find out what the requirements for installation are and how to install Laravel on Ubuntu 22.04.

What are the requirements for Laravel?

There are not many requirements that your system needs to meet in order to use Laravel on Ubuntu 22.04. Since Laravel is a PHP framework, you’ll need to make sure you have PHP installed on your Ubuntu server. The specific PHP version you need depends on which version of Laravel you want to use. The official documentation currently recommends the following:

Laravel version Supported PHP versions
9 8.0 to 8.2
10 8.1 to 8.2
11 8.2
Source: https://laravel.com/docs/10.x/releases (Accessed June 2023)

Although PHP comes installed on Ubuntu by default, you should still check which version you are currently using. To do this, execute the following command in the terminal:

php -v
bash

After entering the command, the output should look like this:

php-version-check.png
You can check the PHP version in the Ubuntu terminal.

In this example, you can see that PHP version 8.1.2 is installed and functioning properly.

Note

If you have set up your server with a minimal installation, you‘ll need to install PHP and configure it before you can proceed.

Laravel developer Taylor Otwell recommends using the PHP package management system Composer. You can find out more about this handy package tool in our step-by-step guide on how to install Composer on Ubuntu.

How to install Laravel on Ubuntu 22.02: Step-by-step instructions

Once you have a compatible PHP version and Composer, you can install Laravel on Ubuntu 22.04. To do this, open the terminal and navigate to your system’s HTML directory.

cd /var/www/html/
bash

To install the PHP framework, execute the following command in this directory:

sudo composer create-project laravel/laravel test-project
bash

Instead of using “test-project”, you can choose a name for the PHP application you want to create with Laravel. If the setup is successful, you will receive a message that says, “Application key set successfully.”

laravel-installation-successfully.png
To start the installation process, use administrator privileges to confirm the execution of the installation via Composer.

After the installation is complete, grant the directory for the Laravel application that you just added (referred to as “test-project” in this tutorial) ownership of the server. You can do this by executing the following commands:

sudo chown -R www-data:www-data /var/www/html/test-project
sudo chmod -R 775 /var/www/html/test-project/storage
bash

To verify the installation, navigate to the directory of the Laravel application and execute the following command:

php artisan
bash
Be secure. Buy an SSL certificate.
  • Secures data transfers
  • Avoids browser warnings
  • Improves your Google ranking

SSL Certificate Checker

SSL Certificate Checker
Tip

It’s best to have MySQL or an alternative database management system installed when working with Laravel. Additionally, having the web server Apache (if not already installed) is also useful. For optimal compatibility, we recommend installing the popular LAMP-stack.

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top