Laravel is an open-source and cross-platform PHP framework that is hailed by web developers everywhere. Laravel is built by Symfony framework and works on model-view-controller pattern. It is highly regarded because it cuts down the grunt work and lets the developers do the real work.
In this article, You will learn how you can install and set up the Laravel framework on your Ubuntu System.
Note: The commands in this tutorial are executed on the Ubuntu 20.04 system. All the methods in the tutorial are valid for any Linux-based system.
It is always the best practice to start any installation with the upgraded and updated system but it is necessary as Laravel does not work with PHP with a version lower than 7.2.
To update and upgrade your system, run the following command.
sudo apt update && apt upgrade -y
To install PHP on your system, run the following apt command.
sudo apt install php
Once you are done with the installation, check the installation version with the following command.
php -v
Now install the PHP extension with the same version with the following command.
sudo apt install php7.4-mbstring php7.4-xml php7.4-zip
Run the following command to install curl if you do not have it installed.
sudo apt install curl
You need the Composer to manage dependencies in Laravel.
To install composer, run the following command.
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Run the following command with your composer file path to run composer without sudo permission.
sudo chown -R $USER /usr/local/bin/composer/
Laravel often uses the Symfony framework so it is best to install it along with Laravel.
To install Symfony run the following command.
composer create-project symfony/skeleton testproj
Change into the testproj directory and run the following command
run php -S 127.0.0.1:8000 -t public
Open the following link in the browser to verify the installation.
Now that everything is set and running, install Laravel using the following composer command.
composer global require laravel/installer
Once the Laravel installation is done, open the .bashrc file.
nano .bashrc
Then add the following line of code at the end of the file.
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
Press Ctrl+O and Ctrl+X to save and exit.
Next source the bashrc file.
source ~/.bashrc
Simply run the following command to create an application in Laravel.
laravel new [name of app]
Navigate to the application directory and run the following composer command.
cd [name of app]
composer install
Now run the following commands to get the encryption key and access to localhost.
php artisan key:generate --ansi
php artisan serve
Note the development server link and open it in the browser.
You can see Laravel is up and running.
This article discusses the installation process of Laravel and all the necessary components to establish a bare-minimum configuration. You can keep using the installation as it is to learn the Laravel basics or add more components like databases or homestead to build elaborate web applications.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…