Advance

How to install Laravel on Ubuntu 20.04 LTS [complete]

How to install Laravel on Ubuntu 20.04 LTS [complete]

To learn about a web application framework, join us to review installing Laravel. With this tool, you would see some of common tasks have been easier such as authentication, routing, sessions, and caching. The main reason of choosing Laravel is to development process a pleasing one for the developer without sacrificing application functionality.In this article, we try to learn you How to install Laravel on Ubuntu 20.04 LTS [complete]. You can check out the packages available in Eldernode to purchase an Ubuntu VPS server.

Tutorial install Laravel on Ubuntu 20.04

To let this tutorial work better, please consider the below Prerequisites:

a non-root user with sudo privileges
To set up, follow our Initial server set up on Ubuntu 20.04 LTS.

Recommended Article: The best VPS for SEO tools

How to install Laravel on Ubuntu 20.04 LTS [complete]

Laravel is one of the PHP language frameworks designed for web application development and works based on MVC. Let’s go through the steps of this article to learn how to install Laravel on Ubuntu 20.04.

 

Step 1: Install LAMP Stack

You must first install the LAMP stack on Ubuntu.

Note: Laravel required PHP 7.2 or higher version for the install.

Now, use the commands below to install PHP.

sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt install -y php7.4 php7.4-gd php7.4-mbstring php7.4-xml 

And, Install Apache2 by running the following command.

sudo apt install apache2 libapache2-mod-php7.4 

Next, Install MySQL with the command below:

sudo apt install mysql-server php7.4-mysql 

 

 

Step 2 : Install Composer

Use the following commands to install the composer

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

Step 3 : Download and Install Laravel

Now it’s time to install Laravel, download the latest version, and install it with the following command.

cd /var/www git clone https://github.com/laravel/laravel.git 

Then follow the instructions below:

cd /var/www/laravel sudo composer install 

Also, follow the instructions below:

chown -R www-data.www-data /var/www/laravel chmod -R 755 /var/www/laravel chmod -R 777 /var/www/laravel/storage 

 

 

Step 4 : Create Environment Settings

Now Create Environment Settings with below command:

mv .env.example .env 

Then follow the instructions below:

php artisan key:generate  Application key set successfully. 

Also, follow the instructions below:

nano .env 
APP_NAME=Laravel APP_ENV=local APP_KEY=base64:WrdferHu7dfkc2OdfLdfBPuxdfHqq2BdfQYhd APP_DEBUG=true APP_URL=http://localhost ... 

Step 5 : Create MySQL User and Database

CREATE DATABASE laravel; CREATE USER 'eldernode'@'localhost' IDENTIFIED BY 'secret'; GRANT ALL ON eldernode.* to 'eldernode'@'localhost'; FLUSH PRIVILEGES; quit 

Now edit the .env file and update database settings.

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=eldernode DB_USERNAME=eldernode DB_PASSWORD=eldernode 

Step 6 : Apache Configuration

nano /etc/apache2/sites-enabled/avalable.conf 

Note: Before running, make sure the nano is installed on the server

Update the configuration with command below:

<VirtualHost *:80>  ServerAdmin [email protected] DocumentRoot /var/www/laravel/public  <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/laravel> AllowOverride All </Directory>  ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined  </VirtualHost> 

Now Reload Apache2 configuration with below command:

sudo systemctl restart apache2

Step 7 : Access Laravel on browser

Congratulations, the installation is complete. you can now enter the IP in the browser and view the Laravel page.

 

Conclusion

In this tutorial, you passed the 7 steps and successfully set up a new Laravel application running on Ubuntu 20.04. So enjoy this accessible, yet powerful, providing powerful tools needed for large, robust applications.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.
  • Jason Welsford
    Jason Welsford
    9 months ago

    This guide does not work, just like the countless others I’ve tried

    Reply
    • Michael Morgan
      Michael Morgan
      9 months ago

      Dear friend, please follow the steps carefully. These tutorials have been tested.

      Reply
  • George
    George
    2 years ago

    Is it possible to optimize battery consumption after installing Ubuntu 20.04 or not?

    Reply
    • Dani
      Dani
      2 years ago

      By installing a program to improve battery consumption, you will both increase battery life and prevent the battery from overheating. To prevent overheating in Linux laptops, TLP is a great tool that controls CPU temperature and extends the battery life of laptops in the long run. You can install it in the terminal using the following command:
      sudo apt install tlp tlp-rdw

      Reply
  • Sandra
    Sandra
    2 years ago

    After installing Ubuntu 20.04, how to install multimedia codecs?

    Reply
    • Dani
      Dani
      2 years ago

      To play all media formats such as music, movies, etc., we need to install several new libraries:
      sudo apt install ubuntu-restricted-extras

      Reply
  • Lisa
    Lisa
    2 years ago

    How long will the LTS release be supported?

    Reply
    • Dani
      Dani
      2 years ago

      Every released version of LTS is supported on desktops and servers for 5 years, and this version is no exception to this Ubuntu rule, and will be supported until 2025.

      Reply
  • Betty
    Betty
    2 years ago

    How to enable theme settings on Ubuntu 20.04?

    Reply
    • Dani
      Dani
      2 years ago

      New dark theme settings can be activated from Settings> Appearance.

      Reply
  • Donald
    Donald
    2 years ago

    How to update the system for security plugins?

    Reply
    • Dani
      Dani
      2 years ago

      You must update the security plugins by running the following command before starting the installation:
      sudo apt-get update
      sudo apt-get upgrade

      Reply
  • Matthew
    Matthew
    2 years ago

    Which path is the main Apache configuration files? Please name them.

    Reply
    • Dani
      Dani
      2 years ago

      The main Apache configuration files in the /etc/httpd/conf/httpd.conf path are generally:
      httpd.conf: Main server settings
      modules.conf: Settings for enabling and disabling Apache modules
      access.conf: can contain access settings.
      srm.conf: Contains some other Apache settings such as DocumentRoot

      Reply
  • Karen
    Karen
    2 years ago

    What resources does Ubuntu 20.04 support?

    Reply
    • Dani
      Dani
      2 years ago

      Ubuntu is suitable for desktop and server use. The current version of Ubuntu supports systems with the following resources:
      Intel x86 (IBM-compatible PC), AMD64 (x86-64), ARMv7, ARMv8 (ARM64), IBM POWER8 / POWER9 (ppc64el), IBM Z zEC12 / zEC13 / z14 and IBM LinuxONE Rockhopper I + II / Emporer I + II (s390x)

      Reply
  • Sarah
    Sarah
    2 years ago

    What should we do to produce a new secure key in Laravel through the composer? please guide me.

    Reply
    • Dani
      Dani
      2 years ago

      You can use the command php artisan key: generate.

      Reply
  • Thomas
    Thomas
    2 years ago

    Do we need to change the value of APP_KEY?

    Reply
    • Dani
      Dani
      2 years ago

      The APP_KEY variable contains a unique key that is automatically generated when installing Laravel via Composer. You do not need to change this value.

      Reply
  • Joseph
    Joseph
    2 years ago

    What are the new features in Ubuntu 20.04 compared to previous versions?

    Reply
    • Dani
      Dani
      2 years ago

      One of the most important changes to the Ubuntu 20.04 LTS is the migration to Kernel 5.4, which has many improvements to hardware support. It also supports WireGuard (a secure VPN topology) and comes with Livepatch (no need to reboot after a kernel update).

      Reply
  • Richard
    Richard
    2 years ago

    Hello, how can we delete things related to a record when we delete it from the database?

    For example, when we delete a post, the comments related to that post are also deleted.

    Reply
    • Dani
      Dani
      2 years ago

      You can set some values for onDelete:
      cascade: It means that if their father is removed, all his children will be removed. For example, deleting an author removes all blog posts and comments.
      set null: After deleting their father in the field related to FK, the value is NULL. For example, the author_id field in the posts table is null.
      restrict: If you set this value, it will not allow the removal of the father if he has a child. This means that as long as an author has a post or comment, you can not delete the author’s record and it gives an error.

      Reply
  • Linda
    Linda
    2 years ago

    What is composer.lock?

    Reply
    • Dani
      Dani
      2 years ago

      composer.lock is a file that holds information about all installed packages and their versions and locks the project to specific versions.

      Reply
  • William.J
    William.J
    2 years ago

    What is the use of a PHP composer?

    Reply
    • Dani
      Dani
      2 years ago

      Using Composer, you can specify the PHP libraries on which your project depends. Composer is used in all modern PHP frameworks and operating systems such as Laravel, Symfony, Drupal, and Magento.

      Reply
  • Elizabeth
    Elizabeth
    2 years ago

    What should we do to use Laravel Mix as a compiler?

    Reply
    • Dani
      Dani
      2 years ago

      You need to install Node.js and Yarn.

      Reply
  • Patricia
    Patricia
    2 years ago

    Hello, thank you for your education;

    Where I do the create-project command I encounter this error:
    “Your requirements could not be resolved to an installable set of packages.”

    Help if you can.

    Reply
    • Dani
      Dani
      2 years ago

      Your PHP version does not match.

      Reply

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day