Joomla security

Implementing a secure Joomla website.

#First create the MariaDB/mySQL database


mysql -u root -p
CREATE DATABASE <YourDatabaseName>;
CREATE USER <UsernameForJoomla>@localhost;
SET PASSWORD FOR '<UsernameForJoomla>'@'localhost' = PASSWORD("<Your Password>");
GRANT ALL PRIVILEGES ON <YourDatabaseName>.* TO '<UsernameForJoomla>'@'localhost' IDENTIFIED BY '<Your Password>' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;


cd /var/www
touch configuration.php
chmod 644 configuration.php

rm -rf /var/www/html

http://<localhost>
(if you get the standard Apache welcome screen, delete the index.html from /var/www)


Configure Joomla


Websitenaam: <Your website name>

Gebruikersnaam/Admin user: <Your admin name>
Admin ww: <Your admin password>

User: <UsernameForJoomla>
User ww: <Your Password>
Database: <YourDatabaseName>
Oude database: Verwijder
Voorbeeld...: Nee

Na grafische installatie:
cd /var/www
mv installation installation_OLD_USED (behalve als al via GUI verwijderd)

chmod 444 configuration.php

http://<localhost>/administrator

 

 

Add the following to the Apache config to BLOCK access from the Internet to the administrator site of Joomla.

vi /etc/apache2/sites-enabled/internal-external-https.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName <YOUR LOCAL IP ADDRESS OF THE INTERNAL WEBSERVER>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www
        ErrorLog ${APACHE_LOG_DIR}/error2.log
        #CustomLog ${APACHE_LOG_DIR}/access2.log combined


        Alias /administrator   /var/www/administrator/
        <Directory /var/www/administrator/>
        <RequireAll>
        Require ip <YOUR INTERNAL IP RANGES>
        </RequireAll>
        </Directory>

</VirtualHost>


<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        ServerName unix4life.nl
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        #CustomLog ${APACHE_LOG_DIR}/access.log combined
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

# Next to block all access from Internet to the Joomla Administrator site BY redirecting all URL traffic to the default website page
Alias /administrator   /var/www/

</VirtualHost>

</IfModule>

 

vi /etc/apache2/conf-available/joomla.conf
#
# The next is not an error! You need this entry for external/internet traffic using URL: <YOUR-WEBSITE>/administrator/administrator 

# the first /administrator will redirect to <YOUR-WEBSITE>, but the URL in address bar will be with /administrator, if someone puts again /administrator behind it they will get the regular login screen again.....that's why the extra alias entry with require ip ;-)

Alias /administrator   /var/www/administrator/
<Directory /var/www/administrator/>
<RequireAll>
Require ip <YOUR INTERNAL IP RANGES>
</RequireAll>
</Directory>

<Directory "/var/www/configuration.php">

Require all denied
</Directory>

DirectoryIndex index.php index.html
<LocationMatch "^/[^/]*\.(php|html|txt).*">
Require all denied
</LocationMatch>
<LocationMatch "^/index\.(php|htm).*">
Require all granted
</LocationMatch>
<LocationMatch "^/google.*\.html">
Require all granted
</LocationMatch>
<LocationMatch "^/robots\.txt">
Require all granted
</LocationMatch>

 

Activate the new config via:

a2enconf joomla

systemctl reload apache2

  Donate now via the Paypal button on the top in US Dollar and on the bottom in Euro