Install Laravel on Ubuntu 22.04 LTS Jammy JellyFish Linux

Tutorial to learn steps to install PHP Laravel framework on Ubuntu 22.04 LTS Jammy JellyFish using command terminal to develop web applications.

PHP needs no introduction, it’s been around for many years to power web applications that need a dynamic programming language to run, but there’s one thing it’s no longer: modern .

Programming languages ​​such as Ruby and Python have become increasingly popular, especially in recent years. They are “cool” and appeal better to the next generation of coders. Considering it’s unfortunate that PHP is getting a bit old and you can tell. It’s exactly there Laravel comes into play. It can be considered a next generation PHP framework and that is what makes it so popular. Inspired by Ruby on Rails and .NET, Taylor Otwell created Laravel to get the most out of PHP and prove that more is possible. Also, he was unhappy with other PHP frameworks. They are no longer contemporary. He not only wants to help developers be more productive, but also shows that clean programming with PHP can be fun again too.

In this article, let’s discuss the initial phase to work with Laravel is to install it on Ubuntu based Linux systems.

Steps to Install Laravel on Ubuntu 22.04 LTS Linux

The steps given here to configure the Laravel framework on Ubuntu 22.04 will also be the same for other Ubuntu versions such as 18.04 or 20.04.

1: System update

First, update your system so that it can have the latest security updates and packages installed. This will also refresh the APT package manager index cache.

sudo apt update && sudo apt upgrade

Also, install git:

sudo apt install git

2. Install LAMP on Ubuntu 22.04

The Laravel framework needs PHP to work. However, here we also install Apache and MySQL on your Ubuntu Linux to serve the application pages, generated on this framework using Apache while to save the data we have MySQL. Therefore, let’s first install the LAMP stack using the command below.

sudo apt install lamp-server^ php php-gd php-mbstring php-xml php-zip php-curl

After the installation is complete, you can check the services of Apache and MySQL are running error free or not.

For Apache:

systemctl status apache2 --no-pager -l


systemctl status mysql --no-pager -l

MySQL Service Status

3. Secure MySQL and create a database

We need a database to store the data generated by your Laravel application project, so here we are using a MySQL database server for that.

However, before creating a database, let’s secure our MySQL server.

First connect to MySQL:

sudo mysql

Set root password:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '[email protected]';

To note: To change [email protected] with a strong password you want to set.

Go out:


Run the secure install script again.

sudo mysql_secure_installation

The script will ask these questions.

Enter password for root user: Enter your set password, then press WALK IN.
Change password for root? Hurry NOTthen WALK IN.
Delete anonymous users? Hurry Yesthen WALK IN.
Forbid remote root login? Hurry Yesthen WALK IN.
Delete the test database and access it? Hurry Yesthen WALK IN.
Reload privilege tables now? Hurry Yesthen WALK IN.

Once done, create a database for Laravel:

Connect to the database, if you are not already:

sudo mysql

Now use the given commands, one by one:

CREATE USER 'youruser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON yourdb.* to 'youruser'@'localhost';

To note: Replace yourdb with the name you want to give to your database, while youruser is the user you want to create while the password is the secret key to protect your created user account.

4. Install PHP Composer for Laravel

To install Laravel and the dependencies required by it to work properly, we need to use Composer. It is a library manager for PHP projects. Well, we can install Composer using the default package manager of our Ubuntu 22.04, however, the version provided by it will not be the latest. We are therefore heading here towards an installation script, officially provided by the developers of this PHP library management tool.

curl -sS | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

Install composer php on Ubuntu 22.04

5. Download the Laravel framework project

Let’s clone the Laravel from its Github repository directly into our web root directory.

Switch to web directory:

cd /var/www

Clone Laravel

sudo git clone

6. Install Laravel on Ubuntu 22.04

Once you have downloaded Laravel to your system, navigate to its directory and use Composer to start the installation process.

cd /var/www/laravel

Use composer

sudo composer install

Once the installation is complete, the permission to modify the files:

sudo chown -R www-data.www-data /var/www/laravel
sudo chmod -R 755 /var/www/laravel
sudo chmod -R 777 /var/www/laravel/storage

—–From there, we’ll show how to configure it to access the Laravel application using Apache——

7. Create the Laravel environment configuration file

We already have a sample environment file, let’s use it to create one for our Laravel application.

In the Laravel directory, run:

sudo cp .env.example .env

Generate an encryption key for your app:

php artisan key:generate

Add the database details:

sudo nano .env

Navigate to the database section and modify the values:

Add Laravel Application Database Details

Save the file using CTRL+Opress the Walk in key, then exit the file using CTRL+X.

8. Apache configuration for PHP Laravel application

Edit the default Apache configuration file and change the path to the web root docs directory. This will direct it to serve the files provided by the Laravel instead of the default Apache page.

sudo nano /etc/apache2/sites-enabled/000-default.conf


        ServerAdmin [email protected]
        DocumentRoot /var/www/laravel/public

                Options FollowSymLinks
                AllowOverride None
                AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

Save the file and restart Apache.

sudo systemctl restart apache2

9. Get the app demo page

We have configured the PHP Laravel framework to access through the Apache web server on port 80, so just open your system’s browser which can access the IP address of the Ubuntu 22.04 where you installed the Laravel and point -the top.

For instance:

Install PHP Laravel Framework on Ubuntu 22.04 Jammy

If you want to know how to use Laravel command line to create and work on various projects without using Apache web server, here is the tutorial for it. Use the Laravel command line

Other Items:

How to install phpMyAdmin with Apache on Ubuntu 22.04 LTS
Install Composer on Ubuntu 22.04 | 20.04 LTS
How To Install Flarum Forum Software on Ubuntu 22.04 | 20.04

Comments are closed.