Advance

How to install Laravel on Ubuntu 20.04 LTS [complete]

How to install Laravel on Ubuntu 20.04 LTS [complete]
0
(0)

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 webmaster@localhost  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.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

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.

32 thoughts on “How to install Laravel on Ubuntu 20.04 LTS [complete]

  1. 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.

    1. 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.

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

  2. 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.

    1. 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.

    1. 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).

    1. 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.

    1. 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)

    1. 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

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

    1. 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.

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

    1. 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

Leave a Reply

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

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