July 2, 2024
Tutorials

How to Install Laravel on Ubuntu 22.04

How to Install Laravel on Ubuntu 22.04

Laravel is a powerful PHP-based framework for building dynamic applications. It is designed for building applications with simple and easy-to-understand syntax. With advanced and convenient features, Laravel simplifies various tasks including authentication, database management, dynamic content management, and built-in security features. These features make Laravel a popular choice for web developers in this modern era of technology.

If you are looking for a simple guide that can assist you in installing Laravel on Ubuntu 22.04, this guide is for you. If you have newer Ubuntu version 24.04, check out this article.

How to Install Laravel on Ubuntu 22.04?

Laravel can be installed on Ubuntu 22.04 using the following procedural steps.

Step 1: Update and Upgrade Ubuntu Packages

Before you begin, update and upgrade the system packages to their latest versions:

sudo apt update && sudo apt upgrade -y

The Ubuntu 22.04 operating system is now fully updated with the latest version of packages.

Step 2: Install PHP and Required Extensions

Use the APT package manager to Install PHP along with the required extensions:

sudo apt install -y php php-common php-gd php-mysql php-curl php-intl php-mbstring php-bcmath php-xml php-zip

The command successfully executed and installed the PHP package on Ubuntu 22.04.

Step 3: Verify PHP Installation

Execute the php –version command to verify if PHP is installed correctly:

php –version

The command returns the output indicating the current version of PHP, such as 8.1.2.

Step 4: Install curl

Use APT package manager to install curl, a command-line tool used for transferring data with URLs:

sudo apt install curl -y

Step 5: Install PHP Composer

Use the curl command to install PHP Composer, a tool that efficiently manages various libraries and packages in PHP projects:

sudo curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/bin –filename=composer

Step 6: Verify Composer Installation

Verify if the Composer is installed correctly on your Ubuntu 22.04 operating system:

composer –version

A release number like 2.6.5 on your screen indicates a successful installation.

How to Initiate a New Project in Laravel?

To initiate a new project in Laravel on the Ubuntu system, follow these steps carefully.

Step 1: Create a New Project

To create a new project in Laravel named “My_First_App”, execute the composer command:

composer create-project laravel/laravel My_First_App

Step 2: Navigate to the Laravel Project Directory

The ls command helps you to locate the newly created Laravel project on your local machine:

ls 

If a new project like My_First_App is created correctly, it will be found on your local drive.

Step 3: Move into My_First_App

To utilize the Laravel project, move to the newly created project directory:

cd My_First_App

You will see that your current directory has been changed to My_First_App.

Step 4: Start the Development Server

Once the aforementioned steps have been completed, launch the Laravel development server locally:

php artisan serve

Your Laravel is now active and accessible at http://127.0.0.1:8000. Open this URL in a web browser to view your Laravel project.

Finally, you can see the Laravel project is live and accessible at localhost: 

Conclusion

Laravel can be installed on the Ubuntu 22.04 machine using just a few simple steps. First, install prerequisites such as PHP and Composer, and then proceed to install Laravel. This guide has demonstrated the complete process of installing Laravel. It has empowered you with the necessary skills to successfully install Laravel on your Ubuntu 22.04 system.

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video