Secure a web server on Debian or Ubuntu Linux

A web server allows to host dynamic content (pages, scripts, images, videos, files…) and make them available on the internet in a fast, reliable, secure and free way.

This article describes how to secure a web server on Debian or Ubuntu Linux.

Prerequisites

Change the SSH port

Secure Shell (SSH) is a secure communication protocol that allows to interact with a remote server.

It is best to change its port to avoid automatic intrusion attempts on port 22.

nano /etc/ssh/sshd_config

Port 5400

service ssh restart

SSH is now available on port 5400.

Customize access to phpMyAdmin

phpMyAdmin is a web interface that manages the web server MySQL databasephpMyAdmin creates a default phpmyadmin alias which is accessible from all domains hosted on the server.

It is best to disable phpmyadmin alias and customize access to phpMyAdmin to avoid automatic intrusion attempts on the /phpmyadmin address.

Disable phpmyadmin alias

nano /etc/phpmyadmin/apache.conf

Comment out the line that creates the /phpmyadmin alias:

# Alias /phpmyadmin /usr/share/phpmyadmin

Listen the port 4200

nano /etc/apache2/ports.conf

After line Listen 80, add:

NameVirtualHost *:4200
Listen 4200

Create a virtual host on port 4200

nano /etc/apache2/sites-available/phpmyadmin

<VirtualHost *:4200>
    DocumentRoot /usr/share/phpmyadmin
</VirtualHost>

a2ensite phpmyadmin

service apache2 reload

phpMyAdmin is now available on port 4200 at http://mydomain.com:4200

» Create and install a firewall on Debian or Ubuntu Linux
» Backup a server on Debian or Ubuntu Linux

Leave a Reply

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

*