How to Install Bagisto on AlmaLinux 8 with LAMP

Install Bagisto on AlmaLinux 8 with Apache, PHP 8.3, MariaDB 10.11, Composer, secure SELinux permissions, HTTPS, and troubleshooting for VPS stores.
A glowing ecommerce storefront beside a database cylinder and illuminated server rack in a dark blue data center.

Install Bagisto on AlmaLinux 8 with Apache, PHP 8.3, MariaDB 10.11, and Composer, then publish the store behind HTTPS. Allow about 20–30 minutes on a fresh VPS, including the interactive Bagisto installer.

Prerequisites

  • AlmaLinux 8.10, updated and reachable over SSH.
  • A root login or a sudo-enabled user.
  • At least 2 GB of RAM and 10 GB of free disk space for the application, dependencies, database, and product media.
  • A domain such as YOUR_DOMAIN with an A record pointing to the VPS; ports 80 and 443 must be reachable.
  • A Linux server from VPSLake with a public IPv4 address.
  • A unique database password and a separate Bagisto administrator password.

This guide installs the maintained Bagisto 2.4 line. It uses PHP 8.3 from Remi’s AlmaLinux-compatible repository and MariaDB 10.11 because those versions match Bagisto 2.4’s current server requirements. The official Bagisto installation documentation covers other deployment methods.

Step 1: Install Apache, PHP 8.3, MariaDB, and required tools

Bagisto needs a PHP version newer than AlmaLinux 8’s original default stream, so enable PHP 8.3 before installing the application packages.

sudo dnf -y update
sudo dnf -y install epel-release dnf-plugins-core
sudo dnf config-manager --set-enabled powertools
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.3 -y
sudo tee /etc/yum.repos.d/MariaDB.repo > /dev/null <<'REPO'
[mariadb]
name=MariaDB 10.11
baseurl=https://rpm.mariadb.org/10.11/rhel/$releasever/$basearch
gpgkey=https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1
module_hotfixes=1
REPO
sudo dnf -y install httpd MariaDB-server MariaDB-client php php-cli php-common php-fpm php-bcmath php-curl php-gd php-intl php-mbstring php-mysqlnd php-opcache php-pdo php-xml php-zip unzip curl policycoreutils-python-utils firewalld
sudo systemctl enable --now firewalld httpd mariadb php-fpm

Set PHP limits that are suitable for catalog images and Composer dependency work. The file is separate from the package defaults, so updates will not overwrite these values.

sudo tee /etc/php.d/99-bagisto.ini > /dev/null <<'INI'
memory_limit = 512M
upload_max_filesize = 100M
post_max_size = 110M
max_execution_time = 300
max_input_time = 300
INI
sudo systemctl restart php-fpm

Check the versions and service state before continuing.

php -v
mariadb --version
sudo systemctl is-active httpd mariadb php-fpm
PHP 8.3.x (cli) ...
mariadb  Ver 15.1 Distrib 10.11.x-MariaDB ...
active
active
active

Step 2: Open only the web ports

The store will use Apache on ports 80 and 443; MariaDB stays local and does not need port 3306 exposed.

sudo firewall-cmd --permanent --zone=public --add-service=ssh
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-services
ssh dhcpv6-client http https

Step 3: Secure MariaDB and create a dedicated database

The hardening script removes anonymous access and test data; the separate database account keeps Bagisto away from MariaDB’s administrative account.

sudo mariadb-secure-installation

Accept the prompts to remove anonymous users, disallow remote root login, remove the test database, and reload privilege tables. Then create the store database. Replace YOUR_DB_PASSWORD before running this command and keep the value for the Bagisto installer.

sudo mariadb <<'SQL'
CREATE DATABASE bagisto CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'bagisto'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD';
GRANT ALL PRIVILEGES ON bagisto.* TO 'bagisto'@'localhost';
FLUSH PRIVILEGES;
SQL

Test the account without putting its password into shell history.

mariadb -u bagisto -p bagisto -e 'SELECT VERSION();'
VERSION()
10.11.x-MariaDB

Step 4: Install Composer securely

Composer downloads Bagisto and its PHP dependencies. Verify the installer checksum first, following the current Composer download instructions, so a damaged or altered installer is not executed.

cd /tmp
curl -fsSL https://getcomposer.org/installer -o composer-setup.php
EXPECTED_CHECKSUM='c8b085408188070d5f52bcfe4ecfbee5f727afa458b2573b8eaaf77b3419b0bf2768dc67c86944da1544f06fa544fd47'
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
test "$EXPECTED_CHECKSUM" = "$ACTUAL_CHECKSUM"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
rm composer-setup.php
composer --version
Composer version 2.x.x 20xx-xx-xx

Step 5: Download Bagisto 2.4

Run Composer as a service account instead of root, and pin the project to the 2.4 release line that supports PHP 8.3.

sudo useradd --system --home-dir /var/www/bagisto --shell /sbin/nologin --user-group bagisto
sudo install -d -o bagisto -g bagisto -m 0750 /var/www
sudo install -d -o bagisto -g bagisto -m 0750 /var/www/bagisto
sudo -u bagisto -H composer create-project --no-dev --prefer-dist --no-interaction bagisto/bagisto /var/www/bagisto '2.4.*'

The command creates .env and generates an application key through Bagisto’s Composer setup hook. Do not start php artisan serve on a public VPS; Apache will serve the application through its public/ directory.

Step 6: Configure Apache and SELinux

Apache must expose only Bagisto’s public directory, pass PHP files to PHP-FPM, and allow Laravel’s rewrite rules to run.

Replace YOUR_DOMAIN in this block with the real hostname before running it.

sudo tee /etc/httpd/conf.d/YOUR_DOMAIN.conf > /dev/null <<'APACHE'
<VirtualHost *:80>
    ServerName YOUR_DOMAIN
    DocumentRoot /var/www/bagisto/public

    <Directory /var/www/bagisto/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>

    DirectoryIndex index.php
    ErrorLog /var/log/httpd/YOUR_DOMAIN-error.log
    CustomLog /var/log/httpd/YOUR_DOMAIN-access.log combined
</VirtualHost>
APACHE
sudo chown -R bagisto:apache /var/www/bagisto
sudo find /var/www/bagisto -type d -exec chmod 0750 {} \;
sudo find /var/www/bagisto -type f -exec chmod 0640 {} \;
sudo chmod -R g+rwX /var/www/bagisto/storage /var/www/bagisto/bootstrap/cache
sudo semanage fcontext -a -t httpd_sys_content_t '/var/www/bagisto(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/bagisto/storage(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/bagisto/bootstrap/cache(/.*)?'
sudo restorecon -Rv /var/www/bagisto
sudo apachectl configtest
sudo systemctl restart php-fpm httpd
Syntax OK

The httpd_sys_rw_content_t labels apply write access only to Laravel’s runtime directories. This keeps SELinux enforcing while allowing logs, cache files, and uploaded media to work.

Step 7: Run the Bagisto installer

The installer writes the database settings, runs migrations, seeds the initial store data, and creates the administrator account.

sudo -u bagisto -H bash -lc 'cd /var/www/bagisto && php artisan bagisto:install'

When prompted, use these values:

  • Application URL: http://YOUR_DOMAIN for the moment.
  • Database name: bagisto.
  • Database user: bagisto.
  • Database password: the value used for YOUR_DB_PASSWORD.
  • Database host: 127.0.0.1 or localhost, matching the database account host.
  • Administrator email and a long, unique administrator password.

After the wizard finishes, point the URL in the generated environment file at the HTTPS address that you will configure next.

sudo -u bagisto sed -i 's#^APP_URL=.*#APP_URL=https://YOUR_DOMAIN#' /var/www/bagisto/.env
sudo -u bagisto -H bash -lc 'cd /var/www/bagisto && php artisan config:clear'

Step 8: Enable HTTPS with Let’s Encrypt

TLS protects customer logins, checkout data, and the administrator session. Run Certbot only after DNS resolves to this server and HTTP traffic can reach port 80.

Replace ADMIN_EMAIL with an address that receives certificate notices.

sudo dnf -y install certbot python3-certbot-apache mod_ssl
sudo certbot --apache --redirect --agree-tos --no-eff-email -m ADMIN_EMAIL -d YOUR_DOMAIN
sudo certbot renew --dry-run
Congratulations, all simulated renewals succeeded

Verify the Bagisto installation

Check the PHP modules, database, service state, and public HTTPS response. A 200 OK or an expected application redirect shows that Apache and PHP-FPM are serving the store.

php -m | grep -E 'bcmath|calendar|curl|gd|intl|mbstring|PDO|pdo_mysql|SimpleXML|xml|zip'
sudo mariadb -e "SHOW DATABASES LIKE 'bagisto';"
sudo systemctl is-active httpd mariadb php-fpm
curl -I https://YOUR_DOMAIN/
bcmath
curl
gd
intl
mbstring
PDO
pdo_mysql
zip
bagisto
active
active
active
HTTP/1.1 200 OK

Troubleshooting

Composer reports that PHP 8.3 is required

The old AlmaLinux PHP stream is still selected, or the Remi module did not replace it. Check the active stream and switch it before running Composer again.

sudo dnf module list php
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.3 -y
sudo dnf distro-sync -y
php -v

SQLSTATE[HY000] [1045] Access denied

The installer’s database password or host does not match the MariaDB account. Test the exact values interactively, and use localhost if the account was created as 'bagisto'@'localhost'; use 127.0.0.1 only if you also create that host-specific account.

mariadb -u bagisto -p bagisto -e 'SELECT 1;'

Apache returns 403 Forbidden or Laravel cannot write to storage

The directory permissions or SELinux labels were changed after the install. Reapply both the group write permissions and persistent contexts, then restart PHP-FPM.

sudo chmod -R g+rwX /var/www/bagisto/storage /var/www/bagisto/bootstrap/cache
sudo restorecon -Rv /var/www/bagisto
sudo systemctl restart php-fpm httpd

503 Service Unavailable or PHP source appears in the browser

PHP-FPM is stopped, or Apache is pointing at a missing socket. Confirm the socket exists and inspect the service log before restarting both services.

sudo systemctl status php-fpm --no-pager
sudo ls -l /run/php-fpm/www.sock
sudo apachectl configtest

FAQ

Does Bagisto work on AlmaLinux 8?

Yes. Bagisto 2.4 runs on PHP 8.3 or 8.4 and supports MariaDB 10.11. AlmaLinux 8’s default PHP stream is older, which is why this guide enables the PHP 8.3 stream before installing Bagisto.

Why does Apache point to the public directory?

Laravel’s front controller and public assets live there. Pointing Apache at the project root could expose environment files, Composer metadata, and application source to web requests.

Do I need Node.js for a normal Bagisto install?

No. A Composer installation includes the application assets needed for a standard deployment. Install Node.js only when you plan to rebuild Bagisto’s storefront, admin, or installer assets.

Where is the Bagisto administrator login?

The default administrator path is https://YOUR_DOMAIN/admin, unless you choose a different admin URL during installation. Use the administrator email and password created by the installer, and change the password immediately if you used a temporary value.

Samrat Ghosh
Written by

Samrat Ghosh

Founder & Infrastructure Engineer

Samrat Ghosh is the founder of VPSLake, where he builds and runs the remote desktop and VPS hosting infrastructure the company is built on. He writes hands-on guides about RDP, Windows Server, VPS management and secure remote access - the practical documentation he wishes had…

Previous Article

5 Best Linode Alternatives in 2026

Write a Comment

Leave a Comment

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

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨