Laravel Installation Guide for AlmaLinux

- - Laravel
SHARE THIS ARTICLE

Step-by-Step Guide to Install Laravel, PHP, Apache, and MySQL on AlmaLinux

Step 1: Update System Packages

Update your system packages:

sudo dnf update -y

Step 2: Install PHP

Enable the EPEL and Remi repositories:

sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y

Enable the Remi PHP 8.x repository:

sudo dnf module enable php:remi-8.2 -y

Install PHP and required extensions:

sudo dnf install php php-cli php-fpm php-mysqlnd php-zip php-gd php-mbstring php-curl php-xml php-bcmath php-json -y

Verify the installation:

php -v

Step 3: Install Apache

Install Apache:

sudo dnf install httpd -y

Start and enable Apache:

sudo systemctl start httpd
sudo systemctl enable httpd

Open the firewall for HTTP and HTTPS:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Verify Apache is running by visiting http://<your-server-ip> in your browser.

Step 4: Install MySQL (MariaDB)

Install MariaDB:

sudo dnf install mariadb-server mariadb -y

Start and enable MariaDB:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure MariaDB:

sudo mysql_secure_installation

Verify MariaDB is running:

sudo mysql -u root -p

Step 5: Install Composer

Download and install Composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Move Composer to a global directory:

sudo mv composer.phar /usr/local/bin/composer

Verify the installation:

composer --version

Step 6: Install Laravel

Create a new Laravel project:

composer create-project --prefer-dist laravel/laravel project-name

Navigate to the project directory:

cd project-name

Set up the .env file:

cp .env.example .env

Update the .env file with your database credentials:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password

Generate an application key:

php artisan key:generate

Set proper permissions for Laravel storage and cache:

sudo chown -R apache:apache storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache

Step 7: Configure Apache for Laravel

Move your Laravel project to the Apache web directory:

sudo mv project-name /var/www/html/

Create an Apache configuration file for your Laravel project:

sudo nano /etc/httpd/conf.d/laravel.conf

Add the following configuration:

<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/project-name/public

<Directory /var/www/html/project-name/public>
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/laravel-error.log
CustomLog /var/log/httpd/laravel-access.log combined
</VirtualHost>

Restart Apache:

sudo systemctl restart httpd

Step 8: Verify Installation

Open your browser and visit http://<your-server-ip>. You should see the Laravel welcome page.

Dependencies Installed

  • PHP
  • Apache (httpd)
  • MariaDB (MySQL-compatible)
  • Composer
  • Laravel

You’re now ready to start building your Laravel application on AlmaLinux! 🚀

Post Tags:
Join the Newsletter

Sign up for our personalized daily newsletter

Kodesmart

#1 GUIDE TO DRUPAL, WORDPRESS, CSS AND CUSTOM CODING | BEGINNER TO PRO