How to Install Laravel on AlmaLinux

In this tutorial, we will show you in detail how to install Laravel on AlmaLinux OS.

Laravel is an open-source web framework written in PHP. Today many websites are made in this framework supported by its large community that is growing on a daily basis. Laravel is Symfony based and follows the MVC architectural pattern. We have many posts about this, but this time we will install it using the LAMP stack on the latest AlmaLinux 9 distribution.

Installing Laravel on AlmaLinux is a straightforward process that may take up to 15 minutes. Let’s get things working!


  • A server with AlmaLinux 20.04 as OS and a Minimum 4GB of RAM
  • Valid domain pointed to the servers IP address
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before starting the installation process, it is necessary to update the system packages to the latest available version.

sudo dnf update -y && sudo dnf upgrade -y

Step 2. Install Apache

We will install the Apache Web server and configure it later for the Laravel website to be accessible via domain name. To install the Apache Web server execute the following command:

sudo dnf install httpd -y

Once installed, start and enable the service.

sudo systemctl enable httpd && sudo systemctl start httpd

Check if the service is up and running:

sudo systemctl status httpd

You should receive the following output:

[root@host ~]# sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2022-11-16 04:58:49 CST; 6h ago
       Docs: man:httpd.service(8)
   Main PID: 566 (httpd)
     Status: "Total requests: 153; Idle/Busy workers 100/0;Requests/sec: 0.00681; Bytes served/sec:  20 B/sec"
      Tasks: 213 (limit: 24833)
     Memory: 40.0M
        CPU: 17.460s
     CGroup: /system.slice/httpd.service
             ├─566 /usr/sbin/httpd -DFOREGROUND
             ├─588 /usr/sbin/httpd -DFOREGROUND
             ├─589 /usr/sbin/httpd -DFOREGROUND
             ├─591 /usr/sbin/httpd -DFOREGROUND
             └─592 /usr/sbin/httpd -DFOREGROUND

Nov 16 04:58:49 host.test.vps systemd[1]: Starting The Apache HTTP Server...

Step 3. Install PHP8.0 with extensions

PHP must be installed on the server since Laravel is a PHP Framework. The repository for PHP8.0 is default added to the latest AlmaLinux 9 OS distribution. We need to execute the following line of commands:

sudo dnf install php php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-json php-readline php-mbstring php-apcu php-xml php-dom -y

Once installed, check the PHP version by executing the php -v on your command line.

[root@host ~]# php -v
PHP 8.0.13 (cli) (built: Nov 16 2021 18:07:21) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Step 4. Install MySQL database server

To install the MySQL database server, execute the following commands:

sudo dnf install mysql-server mysql

Start and enable the mysqld.service with the following commands:

sudo systemctl start mysqld && sudo systemctl enable mysqld

Check the status of the mysqld.service

sudo systemctl status mysqld

You should receive the following output:

[root@host ~]# sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2022-11-16 11:44:56 CST; 3s ago
   Main PID: 2851 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 24833)
     Memory: 456.4M
        CPU: 8.082s
     CGroup: /system.slice/mysqld.service
             └─2851 /usr/libexec/mysqld --basedir=/usr

Nov 16 11:44:44 host.test.vps systemd[1]: Starting MySQL 8.0 database server...
Nov 16 11:44:44 host.test.vps mysql-prepare-db-dir[2769]: Initializing MySQL database
Nov 16 11:44:56 host.test.vps systemd[1]: Started MySQL 8.0 database server.

Step 5. Install Composer

We need to install the Composer, which is required for the installation of all the Laravel components.

curl -sS | php -- --install-dir=/usr/bin --filename=composer

Check the Composer installation:


You should receive the following output:

[root@host ~]# composer
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 2.4.4 2022-10-27 14:39:29

  command [options] [arguments]

  -h, --help                     Display help for the given command. When no command is given display help for the list command
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
      --no-scripts               Skips the execution of all scripts defined in composer.json file.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Step 6. Install Laravel

In this blog post, we will use the default apache2 document root:

cd /var/www/html

composer create-project laravel/laravel "YOUR APPLICATION NAME"

After successful installation, you should receive the following output:

81 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found
> @php artisan key:generate --ansi

   INFO  Application key set successfully.

[root@host html]#

Go into the project directory and set the correct permissions:

cd /var/www/html/project

chown -R apache:apache .

chmod -R 775 storage/

Step 7. Create Apache Virtual Host File

We need to create an Apache virtual host configuration file in order to access the Laravel via the domain name:

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

Paste the following lines of code:

<VirtualHost *:80>
     DocumentRoot /var/www/html/project/public
     <Directory /var/www/html/project/public>
          Options FollowSymlinks
          AllowOverride All
          Require all granted

     ErrorLog /var/log/httpd/yourdomain.com_error.log
     CustomLog /var/log/httpd/ combined

Save the file, close it check the syntax of the Apache configuration file.

httpd -t

You should get this output:

[root@host project]# httpd -t
Syntax OK

Restart the httpd.service.

sudo systemctl restart httpd

Now you can access the Laravel installation at

install laravel on almalinux

We trust that you found our directions on how to install Laravel on AlmaLinux simple and practical.

Now, we’d like to get your input.

Is there an aspect you feel we haven’t covered or a step that’s unclear and needs more detail? Are there other topics or guides you wish to see from us?

We’re eager to hear your thoughts. Please leave a comment below.

Leave a Comment