1. Prepare Your System
- Update Packages:
Run:
sudo apt update && sudo apt upgrade -y
- Install the LAMP Stack:
Install Apache, MariaDB, and PHP with the necessary extensions
sudo apt install apache2 mariadb-server php php-cli php-curl php-json php-intl php-xml php-gd php-mysql php-mbstring php-zip unzip -y
- Secure MariaDB:
Run:
NOTE: apache and nginx cant run at same time on same ip and port no double localhost port at same time =)
- Extract Files to Web Root:
Create a directory for your Joomla site (e.g., in/var/www/html/joomla
) and extract:
sudo mkdir -p /var/www/html/joomla
sudo unzip https://downloads.joomla.org/cms/joomla4/x-x-x/Joomla_x-x-x-Stable_Full_Package.zip -d /var/www/html/joomla
- Set Ownership and Permissions:
Make Apache (typically userwww-data
) the owner:
sudo chown -R www-data:www-data /var/www/html/joomla
sudo find /var/www/html/joomla -type d -exec chmod 755 {} \;
sudo find /var/www/html/joomla -type f -exec chmod 644 {} \;
4. Configure Apache
- Create a Virtual Host:
Create a new Apache configuration file (e.g.,/etc/apache2/sites-available/joomla.conf
):
sudo a2ensite joomla.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
sudo systemctl restart apache2
5. Install Joomla via the CLI Installer
Starting with Joomla 4.3, Joomla offers a CLI installation option that lets you complete the setup without a web browser. This is especially useful on a server without a GUI.
- Run the Joomla CLI Installer:
Change to your Joomla installation directory and run:
cd /var/www/html/joomla
sudo su
php installation/joomla.php install
exit
use exit after install so you leave sudo su
1.2 Https aka ssl
- Install Certbot and the Apache Plugin:
Run the following command to install Certbot and its Apache integration:
sudo apt install certbot python3-certbot-apache -y
- Run Certbot:
Execute Certbot with the Apache plugin, replacing yourdomain.com with your actual domain and providing your email:
sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d yourdomain.com
- Test Renewal:
To ensure automatic renewal is set up correctly, run:
sudo certbot renew --dry-run
now here /etc/apache2/sites-available this should now exist joomla-le-ssl.conf
sudo cd /etc/apache2/sites-available/
sudo nano joomla-le-ssl.conf
nano like a normal person remember that!
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin
ServerName yoursite.com
ServerAlias www.yoursite.com
DocumentRoot /var/www/html/joomla
<Directory /var/www/html/joomla>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/joomla_error.log
CustomLog ${APACHE_LOG_DIR}/joomla_access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/yoursite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yoursite.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
Header always set Strict-Transport-Security "max-age=31536000"
</VirtualHost>
</IfModule>