How to Install Laravel on Ubuntu 20.04

Satish Umagol
2 min readJun 7, 2021

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

Step 1: Install Apache, PHP, MySQL, & Composer

- Install Apache2:

Install Apache using Ubuntu’s package manager, apt

sudo apt install apache2

Once the installation is finished, you’ll need to adjust your firewall settings to allow HTTP traffic. UFW has different application profiles that you can leverage for accomplishing that. To list all currently available UFW application profiles, you can run:

sudo ufw app list

To only allow traffic on port 80, use the Apache profile:

sudo ufw allow in "Apache"

You can verify the change with:

sudo ufw status

- Install MySQL:

Again, use apt to acquire and install this software:

sudo apt install mysql-server

When you’re finished, test if you’re able to log in to the MySQL console by typing:

sudo mysql

You should see output like this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.19-0ubuntu5 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

- Install PHP:

To install these packages, run:

sudo apt install php libapache2-mod-php php-mysql

Once the installation is finished, you can run the following command to confirm your PHP version:

php -v

- Install Composer:

PHP Composer is used for install required dependencies for the PHP application. Execute the following commands to install and configure Composer on your system.

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

Step 2: Install Laravel

- Installation Via Composer:

composer create-project laravel/laravel example-app

cd example-app

php artisan serve

- The Laravel Installer

you may install the Laravel Installer as a global Composer dependency:

composer global require laravel/installer

To put this folder on the PATH environment variable type

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc

For more recent laravel you need to put

echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc

check Laravel vesrion

laravel --version

Let’s start building an awesome application using Laravel PHP Framework.

Conclusion

This tutorial explained to you to create a new Laravel application. Also provided you with steps to configure the Laravel application with Apache webserver.

Thank You…

--

--

Satish Umagol
0 Followers

A Full Stack Developer Working For Open Source