Install Joomla with LAMP Stack on AlmaLinux 9 and finish with a Joomla 6.1.4 website served by Apache, MariaDB, PHP 8.4, and HTTPS. Set aside about 20 minutes for a fresh VPS, including the browser installer.
Prerequisites
- A fully updated AlmaLinux 9 server with at least 2 GB of RAM and 10 GB of available disk space.
- A root shell or a sudo-enabled user connected over SSH. The commands below include
sudofor administrative operations. - A public IPv4 address and
YOUR_DOMAINpointing toSERVER_IP; inbound ports 80 and 443 must be available for the website and certificate challenge. - A long database password, a separate Joomla Super User password, and an email address for certificate renewal notices.
- A VPSLake Linux VPS with root access fits this Apache and MariaDB deployment.
Joomla 6.1.4 requires PHP 8.3 or newer and recommends PHP 8.4. It also needs a supported MySQL-compatible driver, XML, DOM, GD, and related PHP modules; check Joomla’s technical requirements before a future major-version upgrade.
Step 1: Install the LAMP packages
AlmaLinux 9 uses DNF and firewalld, and Apache runs PHP through PHP-FPM rather than the removed mod_php module. The Remi repository provides the recommended PHP stream, while the AlmaLinux repositories provide Apache and MariaDB without exposing the database to the internet.
sudo dnf update -y
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --set-enabled crb
sudo dnf install -y epel-release
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.4 -y
sudo dnf install -y httpd mariadb-server firewalld php php-cli php-common php-fpm php-gd php-intl php-mbstring php-mysqlnd php-opcache php-xml php-zip unzip curl policycoreutils-python-utils certbot python3-certbot-apache mod_ssl
sudo tee /etc/php.d/90-joomla.ini > /dev/null <<'PHP'
memory_limit = 256M
upload_max_filesize = 32M
post_max_size = 32M
max_execution_time = 60
PHP
sudo systemctl enable --now firewalld mariadb php-fpm httpd
Permit SSH and web traffic only. MariaDB will use the local socket, so opening port 3306 would add unnecessary exposure.
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
php -v
sudo systemctl is-active httpd mariadb php-fpm firewalld
PHP should begin with 8.4, and the service check should return four active lines:
PHP 8.4.x (cli) ...
active
active
active
active
Step 2: Prepare MariaDB for Joomla
The MariaDB hardening script removes default accounts and test data before Joomla gets a dedicated local database user.
sudo mariadb-secure-installation
Remove anonymous users, reject remote root login, remove the test database, and reload the privilege tables when prompted. MariaDB package defaults differ slightly, so answer the prompts based on the current state instead of assuming a fixed sequence.
Create a UTF-8 database and grant it to a local-only account. Replace YOUR_DB_PASSWORD with a strong password before running the block; avoid a single quote in the placeholder value unless you also escape it for SQL.
sudo mariadb <<'SQL'
CREATE DATABASE joomla CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'joomla_user'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD';
GRANT ALL PRIVILEGES ON joomla.* TO 'joomla_user'@'localhost';
FLUSH PRIVILEGES;
SQL
sudo mariadb -e "SHOW DATABASES LIKE 'joomla';"
The final command should print one row for joomla. Save the same password for the web installer; Joomla will connect through localhost, not a public database port.
Step 3: Download Joomla and set SELinux-aware permissions
The official Joomla downloads page provides the full package for a new site. This layout keeps core code owned by root while giving Apache write access only to files and directories Joomla must update.
cd /tmp
curl -fL -o Joomla_6-1-4-Stable-Full_Package.zip 'https://downloads.joomla.org/cms/joomla6/6-1-4/Joomla_6-1-4-Stable-Full_Package.zip?format=zip'
sudo mkdir -p /var/www/joomla
sudo unzip -q Joomla_6-1-4-Stable-Full_Package.zip -d /var/www/joomla
sudo cp /var/www/joomla/htaccess.txt /var/www/joomla/.htaccess
sudo chown -R root:apache /var/www/joomla
sudo find /var/www/joomla -type d -exec chmod 0750 {} +
sudo find /var/www/joomla -type f -exec chmod 0640 {} +
sudo install -o apache -g apache -m 0660 /dev/null /var/www/joomla/configuration.php
sudo mkdir -p /var/www/joomla/cache /var/www/joomla/administrator/cache /var/www/joomla/images /var/www/joomla/media /var/www/joomla/tmp /var/www/joomla/administrator/logs
sudo chown -R apache:apache /var/www/joomla/cache /var/www/joomla/administrator/cache /var/www/joomla/images /var/www/joomla/media /var/www/joomla/tmp /var/www/joomla/administrator/logs
sudo find /var/www/joomla/cache /var/www/joomla/administrator/cache /var/www/joomla/images /var/www/joomla/media /var/www/joomla/tmp /var/www/joomla/administrator/logs -type d -exec chmod 0770 {} +
sudo find /var/www/joomla/cache /var/www/joomla/administrator/cache /var/www/joomla/images /var/www/joomla/media /var/www/joomla/tmp /var/www/joomla/administrator/logs -type f -exec chmod 0660 {} +
Keep SELinux enforcing. Register a general web-content label, then override only Joomla’s writable paths with httpd_sys_rw_content_t.
sudo semanage fcontext -a -t httpd_sys_content_t '/var/www/joomla(/.*)?'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/joomla/configuration.php'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/joomla/(cache|administrator/cache|images|media|tmp|administrator/logs)(/.*)?'
sudo restorecon -Rv /var/www/joomla
Step 4: Point Apache at the site
This virtual host selects Joomla as the document root and permits its .htaccess rules, which are needed for friendly URLs. Replace YOUR_DOMAIN and ADMIN_EMAIL before submitting the configuration.
sudo tee /etc/httpd/conf.d/joomla.conf > /dev/null <<'APACHE'
<VirtualHost *:80>
ServerName YOUR_DOMAIN
ServerAdmin ADMIN_EMAIL
DocumentRoot /var/www/joomla
<Directory /var/www/joomla>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.php index.html
ErrorLog /var/log/httpd/joomla-error.log
CustomLog /var/log/httpd/joomla-access.log combined
</VirtualHost>
APACHE
sudo apachectl configtest
sudo apachectl -M | grep rewrite_module
sudo systemctl reload httpd
Syntax OK and rewrite_module (shared) show that Apache accepted the vhost. Before DNS is ready, curl -I http://SERVER_IP/ can confirm that Apache answers on port 80.
Step 5: Add HTTPS with Let’s Encrypt
TLS protects the Super User password and database credentials entered in the browser. Wait for the DNS A record to resolve to this VPS before requesting the certificate.
sudo certbot --apache --redirect --agree-tos --no-eff-email -m ADMIN_EMAIL -d YOUR_DOMAIN
sudo certbot renew --dry-run
Use a monitored address for ADMIN_EMAIL. Certbot adds the TLS configuration and HTTP-to-HTTPS redirect; a successful dry run confirms that automatic renewal can work.
Step 6: Complete the Joomla installer
The browser wizard writes the site configuration and creates Joomla’s initial tables. Open https://YOUR_DOMAIN/ and enter these database values:
- Database type:
MySQLi - Database host:
localhost - Database name:
joomla - Username:
joomla_user - Password: the value used for
YOUR_DB_PASSWORD - Table prefix: keep the generated value
Continue with the site name, administrator email, and a unique Super User name and password. When Joomla reports success, the administrator area is at https://YOUR_DOMAIN/administrator.
After the wizard finishes, lock down the generated configuration file. Joomla can still write to the cache, media, image, log, and temporary directories prepared earlier.
sudo chown root:apache /var/www/joomla/configuration.php
sudo chmod 0640 /var/www/joomla/configuration.php
sudo semanage fcontext -d '/var/www/joomla/configuration.php' 2>/dev/null || true
sudo semanage fcontext -a -t httpd_sys_content_t '/var/www/joomla/configuration.php'
sudo restorecon -v /var/www/joomla/configuration.php
Verify the Joomla LAMP installation
Run these checks from SSH and then open both the public site and administrator URL. They verify services, Apache syntax, PHP modules, the database, the generated configuration, and the HTTPS response.
sudo systemctl is-active httpd mariadb php-fpm firewalld
sudo apachectl configtest
php -m | grep -Ei 'dom|gd|mbstring|mysqli|pdo_mysql|SimpleXML|xml|zip'
sudo mariadb -e "SHOW DATABASES LIKE 'joomla';"
test -f /var/www/joomla/configuration.php && echo configuration.php-present
curl -fsSI https://YOUR_DOMAIN/
Expect four active lines, Syntax OK, the requested PHP modules, a joomla row, configuration.php-present, and either HTTP 200 or a normal Joomla redirect:
active
active
active
active
Syntax OK
configuration.php-present
HTTP/2 200
Troubleshooting
No match for argument: php or PHP is still 8.0
DNF either cannot see Remi or is still using AlmaLinux 9’s base PHP stream. Confirm the repositories, clear cached metadata, and select Remi’s 8.4 stream before installing the PHP packages again.
sudo dnf config-manager --set-enabled crb
sudo dnf install -y epel-release
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf clean all
sudo dnf makecache
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.4 -y
sudo dnf install -y php php-cli php-common php-fpm php-gd php-intl php-mbstring php-mysqlnd php-opcache php-xml php-zip
sudo systemctl enable --now php-fpm httpd
php -v
Access denied for user 'joomla_user'@'localhost'
The installer value does not match the account or password created in Step 2. Check the grant, then test the same credentials from the shell; the password prompt keeps it out of the command history.
sudo mariadb -e "SHOW GRANTS FOR 'joomla_user'@'localhost';"
mariadb -u joomla_user -p -h localhost joomla -e 'SELECT 1;'
Apache serves the default page instead of Joomla
Apache may be using another virtual host because the request hostname does not match ServerName, or DNS still points to a different VPS. List the active vhosts, verify the configured document root, and send a Host header to the local listener.
sudo apachectl -S
sudo apachectl configtest
curl -I -H 'Host: YOUR_DOMAIN' http://127.0.0.1/
Search Engine Friendly URLs return 404 Not Found
Joomla’s rewrite file may not have been copied, or Apache may be ignoring overrides. Make sure .htaccess exists and that the vhost allows overrides, then reload Apache.
sudo test -f /var/www/joomla/.htaccess && echo htaccess-present
sudo grep -E 'AllowOverride|DocumentRoot' /etc/httpd/conf.d/joomla.conf
sudo apachectl configtest
sudo systemctl reload httpd
Hardening
- Keep
configuration.phpowned byroot:apacheat mode0640, and back up the site files and database before core or extension updates. - In Joomla administrator, enable core-update notifications and remove extensions that are no longer maintained.
- Keep MariaDB local and leave port 3306 closed in firewalld.
- After confirming a second SSH login path, use VPSLake’s SSH hardening generator to review a safer SSH baseline.
FAQ
Why is PHP-FPM installed on AlmaLinux 9?
AlmaLinux 9 removed the old Apache mod_php handler, so PHP-FPM is the supported way for Apache to execute PHP. The package and service commands above install the standard FastCGI integration and start it at boot.
What should remain writable after installation?
Joomla needs write access to its configuration during setup and to areas such as cache, media, images, logs, and temporary files during normal use. The commands above leave those paths writable while the main application files stay owned by root.
How do I enable clean Joomla URLs?
The vhost already permits .htaccess overrides and the setup copies Joomla’s rewrite template into place. After signing in to the administrator area, enable Search Engine Friendly URLs in the global configuration and test an article link.
Can I test the site before DNS changes finish?
Yes. curl -I -H 'Host: YOUR_DOMAIN' http://127.0.0.1/ tests Apache’s vhost locally, while your browser still needs DNS or a temporary hosts-file entry. Let’s Encrypt will not issue a certificate until the public domain resolves to the VPS.