How To Install Laravel 7 Framework on Ubuntu 16.04/18.04/20.04

Laravel is a famous open-source PHP structure focused on simple improvement of utilizations. On the off chance that you are searching for another PHP structure to attempt, you should check out Laravel.

In this post, We will install Laravel on ubutnu 16.04 | 18.04 | 20.04

Step 1: Update system

You need to update the current ubuntu repository and upgrade it by using the following command.

$ sudo apt-get update 
$ sudo apt-get upgrade -y

Step 2: Install Apache Web Server.

$ sudo apt-get install apache2 -y

Get the status of the Apache web server.

$ sudo systemctl status aopache2.service.

Step 3: Install PHP 7.4

To add the PHP 7.4 repo in ubuntu, Use the following commands with root privileges.

$ sudo -i
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update 
$ sudo apt-get install php7.4 -y
$ sudo apt-get install  php7.4-curl php-pear  php7.4-gd  php7.4-dev  php7.4-zip php7.4-mbstring php7.4-mysql php7.4-xml

Step 4: Install Laravel 

$ cd /tmp
$ curl -sS | php
$ sudo mv composer.phar /usr/local/bin/composer
$ cd /var/www/html
$ sudo composer create-project laravel/laravel your-project –prefer-dist

Step 5: Configuring Apache

$ sudo chgrp -R www-data /var/www/html/your-project
$ sudo chmod -R 775 /var/www/html/your-project/storage

$ sudo vim /etc/apache2/sites-available/laravel.conf

Add the configuration.

<VirtualHost *:80>
    ServerName yourdomain.tld

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/your-project/public

    <Directory /var/www/html/your-project>
        AllowOverride All

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

$ sudo a2dissite 000-default.conf
$ sudo a2ensite laravel.conf
$ sudo a2enmod rewrite
$ sudo service apache2 restart

Step 6: Testing Laravel

Open the browser with http://localhost

How To Install Laravel 7 Framework on Ubuntu 16.04/18.04/20.04

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top