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
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
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:
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
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:
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
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.
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
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:
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.
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.