Install Laravel on Ubuntu 20.04

Among the web development frameworks, Laravel is always heard and is the priority of developers to improve and develop complex web applications. Since the PHP programming language is one of the best programming languages in the field of web design, Laravel is a PHP programming language framework that is provided as an open source and free and is based on the MVC architecture and the Symphony framework. Usually, it creates PHP-based web applications by delivering intelligent features.

It also follows the model-view-controller architecture pattern. Using Laravel, you can change many parts’ functionality without changing the main code. In addition, it offers various services such as Artisan console, user access, authentication, cache, template engine, database transfer system, payment, billing, etc. its best features are Laravel’s unparalleled security, development speed, and scalability. Laravel has made the development of web-based applications easier and faster by providing advanced tools and unique features.

This article will teach you how to install Laravel on Ubuntu 20.04. However, the instructions provided in this tutorial are applicable to any Ubuntu-based distribution, including Linux Mint, Kubuntu, and Elementary OS. It should also be noted that the most stable version of the Ubuntu operating system is the LTS version. For operating environments, the LTS version is the latest and best version. If you are interested in using Laravel after purchasing a Linux VPS, you can, Through this tutorial, install Laravel on Ubuntu 20.04 and enjoy the wonderful features of Laravel on Ubuntu. Join us to install Laravel on Ubuntu 20.04 easily.

Steps to install Laravel on Ubuntu 20.04

Step 1: Install Apache web server

To host the Laravel program, you need to install a web server, which can install either Nginx or Apache web servers. To choose one of the two proposed web servers, you can Compare Apache with Nginx and select one after familiarizing yourself with them. In this tutorial, we preferred installing the Apache web server. For this purpose, enter the apache2 command:

After installing the Apache web server, you should see it running. If it doesn’t work for any reason, start Apache:

Then enter the following command to enable Apache at boot time:

You can check the Apache status and make sure it is running without errors using the following command:

Step 2: Installing PHP and its additional plugins

PHP 7.3 and above is a prerequisite for using Laravel 8, which is available in the Ubuntu repositories, PHP 7.4. As a result, type the following command to install PHP and its required modules:

Verify the PHP version after successfully installing PHP using the following command:

Step3: creating a database

To store the data generated by the Laravel program, you need a database. At this stage, you must create a database for the Laravel program. Since Laravel is compatible with MariaDB, MySQL, SQLite, Postgres, or SQL Server database systems, we will install the MariaDB database engine:

To access the MariaDB prompt after installing the database server, you need to use the following command:

Sign in, then make a database and a user for it; grant the database user the necessary permissions.

How to install lavarel on ubuntu 20.04

Step 4: Install Composer

Composer is a package manager and prerequisite management tool for PHP and manages the libraries and dependencies required by PHP based on the particular framework. In this section, we will use it to download the Laravel core and install all the necessary Laravel components, so to install Composer, it is required to download the Composer installer (composer. phar file) by executing the curl command and move the file to the usr/local/bin/ directory:

After executing the above command, the composer. phar file will be downloaded, and to move the file to the usr/local/bin/ path, run the following command:

Assign authority to execute:

Verifying the Composer version after installing it is done through the following command:

Step 5: Install Laravel 8 on Ubuntu

After completing Composer installation, it is time to install Laravel.

To install Laravel, you must first go to the webroot directory, and for this purpose, you must type the following command:

Then, to install Laravel, you must use the create-project command for the composer:

With the help of this command, you create a new directory called laravelapp to install the necessary files and directories of Laravel. The web server user is set to own the Laravel directory:

Then you can choose a new directory name for laravelapp.

Once the installation process is finished, go to the installation directory to check the version of Laravel:

Step 6: Configure Apache to serve Laravel

To host a Laravel site, it is necessary to configure the Apache web server, and for this purpose, you must launch the virtual host file:

In this step, skip the displayed content and change the example.com address of the ServerName Instructions to the fully qualified domain name (FQDN) or the server’s public IP (or private IP if the server is located in a LAN network).

Now you need to save the changes made and close the file. In the next step, you must execute these two commands to activate the Laravel site and the Apache rewrite module.

For your changes to take effect, restart Apache with the following command:

Step 7: Run Laravel in a web browser

Finally, to access Laravel, refer to the Fully Qualified Domain Name (FQDN) or IP address of the server where you installed Laravel. If you do not specify a URL, Laravel will use the default URL. If you followed the steps correctly and the installation was successful, you will be presented with the Laravel page.


Source: https://operavps.com/docs/install-laravel-on-ubuntu/