The PHP framework Laravel provides an extensive col­lec­tion of libraries and com­pon­ents for PHP de­vel­op­ment. Here you can find out what the re­quire­ments for in­stall­a­tion are and how to install Laravel on Ubuntu 22.04.

What are the re­quire­ments for Laravel?

There are not many re­quire­ments 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 doc­u­ment­a­tion currently (as at June 2023) re­com­mends the following:

Laravel version Supported PHP versions
9 8.0 to 8.2
10 8.1 to 8.2
11 8.2

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:

Image: Ubuntu terminal: PHP version check
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 func­tion­ing properly.

Note

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

Laravel developer Taylor Otwell re­com­mends using the PHP package man­age­ment 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 in­struc­tions

Once you have a com­pat­ible 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 ap­plic­a­tion you want to create with Laravel. If the setup is suc­cess­ful, you will receive a message that says, ‘Ap­plic­a­tion key set suc­cess­fully.’

Image: Ubuntu terminal: PHP framework Laravel successfully installed
To start the in­stall­a­tion process, use ad­min­is­trat­or priv­ileges to confirm the execution of the in­stall­a­tion via Composer.

After the in­stall­a­tion is complete, grant the directory for the Laravel ap­plic­a­tion 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 in­stall­a­tion, navigate to the directory of the Laravel ap­plic­a­tion and execute the following command:

php artisan
bash
SSL Cer­ti­fic­ate Checker
Tip

It’s best to have MySQL or an al­tern­at­ive database man­age­ment system installed when working with Laravel. Ad­di­tion­ally, having the web server Apache (if not already installed) is also useful. For optimal com­pat­ib­il­ity, we recommend in­stalling the popular LAMP-stack.

Go to Main Menu