npressfetimg-2280.png

How To Install PHP Laravel on Almalinux | Rocky linux 8 – Linux Shout

Tutorial to learn the steps for installing PHP Larvel framework on Rocky Linux or Almalinux 8 using the command terminal for developing web apps.

PHP doesn’t need an introduction, it has been around for many years powering web applications that need a dynamic programming language to work but one thing it is definitely not (anymore): modern.

Programming languages ​​such as Ruby and Python have become increasingly popular, especially in recent years. They are “cool” and appeal better to the next generation of coders. Whereas it is unfortunate PHP is getting a bit old and you can tell. This is exactly where Laravel comes into play.  We can consider it as a new generation PHP framework and that’s what makes it so popular. Inspired by Ruby on Rails and .NET, Taylor Otwell created Laravel to get the most out of PHP and to prove that more is possible. Also, he wasn’t satisfied with the other PHP frameworks. They are no longer contemporary. He doesn’t only want to help developers be more productive but also to show that clean programming with PHP can also be fun again.

In this informative article, let’s touch the initial phase to work with Laravel is to install it on RedHat based Linux systems.

Install Laravel on Almalinux 8 | Rocky linux 8

The steps given here to setup Laravel will be applicable for all popular Redhat based systems such as Oracle Linux, Rocky, CentOS 9 Stream and others.

1. Requirements

RedHat Linux such as Rocky or AlmaLinux
A non-root sudo user PHP >= 7.2.5
Internet connection

2. Install PHP 8.x

Well, being PHP based framework, PHP language must be on your system. Follow the given commands to get the latest PHP 8.x on your system:

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf update
sudo dnf module reset php
sudo dnf module enable php:remi-8.0
sudo apt install php


Also, install unzip and curl, if you don’t have already:

sudo dnf install unzip curl

 

3. Installing PHP Composer

The easiest way to setup Laravel project is to use the Composer. It is application-level package manager to download, manage and install the dependenices of PHP software and required libraries.

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

To check version:

composer -v

 

4. Installing the Laravel on AlmaLinux 8 | Rocky Linux 8

Laravel is not like PHP to install via the default base repository of Almalinux or Rocky, therefore, here Composer comes in to the picture to install the libraries and dependecies required by Laravel.

composer global require "laravel/installer"

Add the composer bin folder to your system path so that we can use easily run the Laravel command tool anywhere in the terminal regardless the current directory in which we are.

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

Reload bash

source ~/.bashrc

Check the Laravel

Once the installation is completed we can check this PHP framwework is working on our system.

laravel

 

Create a New Laravel Project

laravel new command will create a fresh Laravel installation in the directory you specify after the command. Inside which you can start developing and saving your project files.

laravel new myfirstapp

myfirstapp is a direcotry name you can given whatever you want

Switch to created direcorty:

cd myfirstapp
php artisan serve

To run in the developement server in background to free Terminal, you can use:

php artisan serve &

This will start tarting Laravel development server, open your browser and point it at: http://127.0.0.1:8000

Alternatively, if you don’t want to install Laravel globally, you can simply use the composer and create the project direcotry with laravel files requiored to develop the project.

composer create-project laravel/laravel my-app
cd my-app
php artisan serve

 

To know more, you can refer the offcial documentation of Laravel

 

 

 

Other Articles:

How to install Apache, MySQL and PHP on AlmaLinux 8
How To install Flarum Forum software on Ubuntu 22.04 | 20.04

 

Source: https://www.how2shout.com/linux/how-to-install-php-laravel-on-almalinux-rocky-linux-8/

Related Posts