December 22, 2024
Tutorials

How to Install Laravel on Ubuntu 24.04

install laravel on Ubuntu

Laravel is a PHP framework. It is widely used and known for its simplicity and efficiency in building web-based applications. It allows modern tools and features to streamline development, including database management.

This technical guide provides essential steps on how to set up a Laravel on Ubuntu 24.04 system. Refer to this article if you are using older version i-e Ubuntu 22.04.

How to install Laravel on Ubuntu 24.04?

Follow the below-guided steps to install Laravel on your Ubuntu 24.04 system.

Step 1: Update and Upgrade Your System Files

It is a good practice to keep your system up to date and upgrade. This will help you to run your system smoothly and efficiently:

sudo apt update

If your system needs to install the newest files for the installed packages, you can run the upgrade command:

sudo apt upgrade -y
 

Once your Ubuntu 24.04 machine has been configured with the latest package files, you can proceed to the installation process.

Step 2: Install the “Curl” Package

To download the packages from the internet, you are required to install the “Curl” tool using the command:

sudo apt install curl -y

If your system has installed the curl tool, you will see the above message on your screen.

Step 3: Install the PHP Package

Laravel requires PHP and associated extensions. To install these required files, run the command provided below:

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

The output mentioned above shows that the command executed successfully and as a result, all the required packages have been configured on your Ubuntu 24.04 system.

Step 4: Confirm PHP Installation

After installing the PHP packages, utilize the following code to view the installed version of PHP:

php -v

It can be seen in the output that the currently installed version of PHP is 8.3.6 on your Ubuntu 24.04.

Step 5: Install Composer for PHP and Laravel

It is a necessary step for running the Laravel package on your machine. Thus, utilize the below command to download and install the composer package on your Ubuntu 24.04 machine:

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

Composer 2.7.6 is now successfully installed on your machine without encountering any errors.

Step 6: Verify Composer Installation

You can use the “composer” command followed by the “-v” option to verify the installed version of the Composer package:

composer -v
 

As you can see the “-v” option also displays some important commands on your terminal. These commands can be further used according to your needs.

How to Create a Laravel Project on the Ubuntu 24.04 System?

Let’s follow these steps to create a Laravel project on your Ubuntu 24.04 machine.

Step 1: Create a Laravel Project

Through the following simple command, you can create a Laravel project on your system:

composer create-project laravel/laravel Proj_Green_WB
 

After initiating the Laravel project, such as Proj_Green_WB, you may encounter the above error regarding missing SQLite on your system.

Step 2: Install SQLite for PHP

Let’s fix the above error by installing the SQLite package on your Ubuntu 24.04 machine:

sudo apt install php8.3-sqlite3 -y

Step 3: Configure and Migrate Database

After installing the SQLite, utilize the following command to configure and migrate the SQLite database:

php artisan migrate

This command will set up your database schema on your Ubuntu 24.04 system.

Step 4: Initiate the Laravel Server

Once all the above commands are executed successfully, start the Laravel development server:

php artisan serve

This command will provide a server link for the Laravel application.

Step 5: Access the Laravel Application

Copy the provided link to the web browser to access the Laravel application:

127.0.0.1:8000

Finally, you will see the Laravel development page containing documentation, Laravel News, and Laravel version (v11.8.0).

Conclusion

Install Laravel on your Ubuntu 24.04 system with a few commands. To run the Laravel development server, ensure you have installed the PHP, Composer, and SQLite on your Ubuntu machine. This technical post provided a detailed guide to installing Laravel on your Ubuntu 24.04 system.

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video