Joomla Installation on Linux Server
Joomla is a powerful, user-friendly content management system built on PHP that enables the creation of sophisticated web applications and dynamic content-driven websites. With strong community support and extensive extensibility through components and modules, Joomla powers millions of websites globally. This guide provides a complete walkthrough for installing Joomla on a Linux server with Apache or Nginx, configuring MySQL, hardening security, and optimizing performance.
Table of Contents
- Prerequisites
- System Requirements
- LAMP Stack Installation
- PHP Configuration
- Database Setup
- Joomla Installation
- Web Server Configuration
- SSL and HTTPS
- Security Hardening
- Post-Installation Setup
- Backup Strategy
- Conclusion
Prerequisites
Before installation, verify you have:
- Ubuntu 20.04 LTS or later running on your server
- Root or sudo privileges
- A valid domain name
- Minimum 2GB RAM (4GB+ recommended)
- 15GB available disk space
- Basic Linux administration knowledge
Update system packages:
sudo apt update && sudo apt upgrade -y
System Requirements
Joomla requires specific software versions for optimal operation. Check your environment:
View Linux distribution and kernel:
cat /etc/os-release
uname -r
Check available memory:
free -h
Check available disk space:
df -h /var/www
LAMP Stack Installation
Install the complete Linux, Apache, MySQL, and PHP stack:
Install Apache web server:
sudo apt install -y apache2 apache2-utils apache2-doc
Install MySQL Server:
sudo apt install -y mysql-server mysql-client
Install PHP 8.0 or later:
sudo apt install -y php php-common php-mysql php-curl php-gd php-json php-mbstring php-xml php-xmlrpc php-opcache php-soap php-zip
Verify PHP version:
php --version
Verify extensions are loaded:
php -m | grep -E "curl|gd|json|mbstring|mysql|xml|zip"
Enable Apache modules:
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod ssl
sudo a2enmod proxy
Start services:
sudo systemctl start apache2
sudo systemctl start mysql
sudo systemctl enable apache2
sudo systemctl enable mysql
PHP Configuration
Configure PHP for Joomla requirements:
Edit PHP configuration:
sudo nano /etc/php/8.0/apache2/php.ini
Update these critical settings:
memory_limit = 256M
max_execution_time = 300
upload_max_filesize = 100M
post_max_size = 100M
max_input_vars = 5000
date.timezone = UTC
Edit PHP-CLI configuration:
sudo nano /etc/php/8.0/cli/php.ini
Apply same settings. Restart Apache:
sudo systemctl restart apache2
Database Setup
Secure MySQL installation:
sudo mysql_secure_installation
Create Joomla database:
sudo mysql -u root -p << EOF
CREATE DATABASE joomla;
CREATE USER 'joomla'@'localhost' IDENTIFIED BY 'ComplexPassword123!';
GRANT ALL PRIVILEGES ON joomla.* TO 'joomla'@'localhost';
FLUSH PRIVILEGES;
EXIT;
EOF
Verify database access:
mysql -u joomla -p -h localhost joomla
show tables;
exit;
Joomla Installation
Create web directory:
sudo mkdir -p /var/www/joomla
sudo chown -R www-data:www-data /var/www/joomla
Download latest Joomla version:
cd /tmp
wget https://downloads.joomla.org/cms/joomla4/stable-4/Joomla_4-latest-Stable-Full_Package.zip
unzip Joomla_4-latest-Stable-Full_Package.zip
Copy files to web root:
sudo cp -r /tmp/joomla/* /var/www/joomla/
sudo cp /tmp/joomla/.htaccess /var/www/joomla/
Set correct permissions:
sudo chown -R www-data:www-data /var/www/joomla
sudo find /var/www/joomla -type f -exec chmod 644 {} \;
sudo find /var/www/joomla -type d -exec chmod 755 {} \;
sudo chmod 777 /var/www/joomla/configuration.php
Web Server Configuration
Apache Configuration
Create virtual host:
sudo nano /etc/apache2/sites-available/joomla.conf
Add configuration:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/joomla
<Directory /var/www/joomla>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
ErrorLog ${APACHE_LOG_DIR}/joomla_error.log
CustomLog ${APACHE_LOG_DIR}/joomla_access.log combined
</VirtualHost>
Enable site and disable default:
sudo a2ensite joomla.conf
sudo a2dissite 000-default.conf
Test and reload Apache:
sudo apache2ctl configtest
sudo systemctl reload apache2
Enable .htaccess support:
sudo nano /var/www/joomla/.htaccess
Verify the RewriteBase is set correctly.
Nginx Configuration
Create Nginx configuration:
sudo nano /etc/nginx/sites-available/joomla.conf
Add configuration:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/joomla;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
Enable configuration:
sudo ln -s /etc/nginx/sites-available/joomla.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
SSL and HTTPS
Install Certbot for Let's Encrypt SSL certificates:
sudo apt install -y certbot python3-certbot-apache
Obtain SSL certificate:
sudo certbot certonly --apache -d example.com -d www.example.com
Update Apache configuration to use HTTPS:
sudo nano /etc/apache2/sites-available/joomla.conf
Replace content with:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/joomla
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
<Directory /var/www/joomla>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/joomla_ssl_error.log
CustomLog ${APACHE_LOG_DIR}/joomla_ssl_access.log combined
</VirtualHost>
Enable SSL modules:
sudo a2enmod ssl
sudo apache2ctl configtest
sudo systemctl reload apache2
Security Hardening
Disable PHP execution in upload directories:
sudo nano /var/www/joomla/images/.htaccess
Add:
php_flag engine off
<FilesMatch "\.php$">
Deny from all
</FilesMatch>
Rename configuration file after installation:
sudo mv /var/www/joomla/configuration.php /var/www/joomla/configuration.php.bak
Remove installation folder after setup:
sudo rm -rf /var/www/joomla/installation
Disable file editing in Joomla admin:
Update configuration.php in Joomla admin panel and set:
- System → Global Configuration → Server → File Permissions → Disable "Edit Core Files"
Configure security headers in Apache:
sudo nano /etc/apache2/sites-available/joomla.conf
Add to VirtualHost:
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-XSS-Protection "1; mode=block"
Header always set Referrer-Policy "no-referrer-when-downgrade"
Configure web application firewall:
sudo apt install -y libapache2-mod-security2
sudo a2enmod security2
sudo systemctl reload apache2
Post-Installation Setup
Access Joomla installation wizard at https://example.com and complete setup:
- Configure site name, description, and admin email
- Database configuration (host: localhost, name: joomla, user: joomla)
- Create admin account with strong password
- Remove installation folder
Verify installation completion:
ls -la /var/www/joomla/installation
Should be empty or removed.
Configure SEF URLs in Joomla:
- Login to admin panel
- System → Global Configuration → SEO Settings
- Enable "Search Engine Friendly URLs"
Configure SMTP for email:
- System → Global Configuration → Server
- Set Mail from name and email
- Configure SMTP server details
Backup Strategy
Create backup script:
sudo nano /usr/local/bin/joomla-backup.sh
Add:
#!/bin/bash
BACKUP_DIR="/backups/joomla"
JOOMLA_DIR="/var/www/joomla"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
# Database backup
mysqldump -u joomla -p'ComplexPassword123!' joomla | gzip > "$BACKUP_DIR/joomla-db-$DATE.sql.gz"
# Files backup
tar -czf "$BACKUP_DIR/joomla-files-$DATE.tar.gz" "$JOOMLA_DIR"
# Keep only 30 days
find $BACKUP_DIR -type f -mtime +30 -delete
echo "Backup completed: $DATE"
Make executable:
sudo chmod +x /usr/local/bin/joomla-backup.sh
Schedule daily backups:
sudo crontab -e
Add:
0 2 * * * /usr/local/bin/joomla-backup.sh >> /var/log/joomla-backup.log 2>&1
Conclusion
Joomla is now fully installed, configured, and secured on your Linux server. The combination of Apache/Nginx, MySQL database, SSL encryption, and security hardening provides a robust platform for your web presence. Maintain regular backups, keep extensions updated, and monitor your site's performance for optimal operation. Leverage Joomla's powerful features and extensive component library to build engaging web experiences.


