Tech guide
Tech guide
Introduction
This guide provides step-by-step instructions to set up a secure web server using
Apache on a Linux-based system. The focus is on security best practices to
safeguard sensitive data and prevent unauthorized access.
Prerequisites
A Linux server (Ubuntu or CentOS recommended).
Root or sudo access.
A registered domain name (optional but recommended).
Step 1: Install Apache
Run the following command to install Apache:
sudo apt update && sudo apt install apache2 -y
For CentOS:
sudo yum install httpd -y
Start and enable the service:
sudo systemctl start apache2
sudo systemctl enable apache2
Step 2: Secure the Server with SSL
Install Certbot and obtain an SSL certificate:
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache
Follow the prompts to generate and configure the certificate.
Step 3: Configure the Firewall
Allow necessary traffic:
sudo ufw allow 'Apache Full'
Step 4: Harden Security Settings
Disable directory listing:
sudo nano /etc/apache2/apache2.conf
Find and change Options Indexes FollowSymLinks to Options FollowSymLinks.
Restart Apache:
sudo systemctl restart apache2
Step 5: Test and Monitor
Verify SSL status:
sudo systemctl status apache2
Use security tools like fail2ban to prevent brute-force attacks.
Conclusion
Following these steps will ensure your web server is secure and optimized for
performance. Regular updates and monitoring are recommended to maintain
security.