How to Install Laravel on Ubuntu 22.04

Laravel is a PHP framework that is famous for its user-friendly features and functionalities. Its syntax is simple and clean, contributing to enhanced readability. Furthermore, Laravel provides modern tools for security, authentication features, and interactive database services.

This educational guide covers the complete process of installing Laravel on Ubuntu 22.04.

How to Install Laravel on Ubuntu 22.04?

It is easy to install Laravel on your Ubuntu 22.04 system through the provided steps.

Step 1: Update Ubuntu Packages

To enhance the performance of your Ubuntu machine, always keep your system up to date through the simple command:

sudo apt update
How to Install Laravel on Ubuntu 22.04

Before installing packages, ensure the most recent package versions are installed on your Ubuntu 22.04 system.

Step 2: Install PHP Using APT

PHP and its necessary files and extensions can be installed through the APT package installer from the official Ubuntu repository:

sudo apt install php php-common php-gd php-mysql php-curl php-intl php-mbstring php-bcmath php-xml php-zip -y
How to Install Laravel on Ubuntu 22.04
How to Install Laravel on Ubuntu 22.04

No errors occur during the setup process of PHP, indicating that the package has been successfully installed and configured on your Ubuntu machine.

Step 3: Display Installed PHP Version

You can confirm the version number of the PHP after installation: 

php -v
How to Install Laravel on Ubuntu 22.04

Currently, PHP 8.1.2 is running on our Ubuntu system.

Step 4: Download and Install Composer Using Terminal 

Composer is a fundamental tool for building projects with the required libraries. In Laravel, it plays a vital role in project management including adding, updating, and removing packages:

sudo curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/bin –filename=composer
How to Install Laravel on Ubuntu 22.04

The command has successfully downloaded Composer from the official website and installed it on your system.

Step 5: Display Composer Version

Run the command to view the installed version of Composer on your system:

composer -v
How to Install Laravel on Ubuntu 22.04

The -v flag will display the Composer version, such as 2.6.6, along with other useful options on your screen.

Step 6: Create a Laravel Project 

To initiate a new Laravel project on your local machine, utilize the Composer manager:

composer create-project laravel/laravel ~/Documents/test_app
How to Install Laravel on Ubuntu 22.04
How to Install Laravel on Ubuntu 22.04

After executing the command, it configures the basic structure and files for a new Laravel project in the specified directory, such as ~/Documents/test_app.

Step 7: Go to the Project Directory

Use the cd command to go into the Laravel project directory.

cd ~/Documents/test_app
How to Install Laravel on Ubuntu 22.04

Now, you are in ~/Documents/test_app, the Laravel project directory.

Step 8: Initiate Laravel Development Server

Upon completing the setup steps, run the command from the terminal to start the Laravel server:

php artisan serve
How to Install Laravel on Ubuntu 22.04

The command establishes a server link for your Laravel. 

Step 9: Access Your Laravel Server

Copy the provided link from the terminal and paste it into your web browser to access the Laravel server: 

127.0.0.1:8000
How to Install Laravel on Ubuntu 22.04

If you see the Laravel page in your web browser, it indicates that Laravel has been set up successfully on your Ubuntu 22.04 system.

Conclusion

You can use a few commands to install Laravel on your Ubuntu 22.04 operating system. First, ensure you have installed the PHP package and Composer, the PHP dependency manager. Finally, initiate the Laravel project using Composer. 

The educational post provides a detailed guide to installing Laravel on Ubuntu 22.04.

For more how-tos and tutorials, visit Green Webpage knowledgebase.

Founder of itnixpro.com|Linux Engineer|Author at Itnixpro.com

Leave a Comment