Home

About Us

Advertisement

Contact Us

PRIVACY POLICY

  • Facebook
  • X
  • Instagram
  • Pinterest
  • WhatsApp
  • RSS Feed
  • TikTok
ALT

Maalavs Blog

Your Trusted Voice Across the World.

  • NEWS
  • Linux Tech Blogs
  • Windows Tech Blogs
  • VIRTUALIZATION Blogs
Search

📌Linux Server Administration: Setting Up, Managing & Monitoring Web Servers

Author: Madhan Gopalakrishnan | Published on : 19-02-2025

Linux Server Administration is a crucial skill for web hosting, application deployment, and network management. This guide will take you through the essential steps of setting up and managing web servers in a Linux environment.


🛠️ Web Servers Overview

A web server is a system that serves web pages to users based on their requests via a browser. The two most popular web servers in Linux are:

Web ServerDescription
Apache 🌍Feature-rich, highly configurable, and widely used
Nginx ⚡High-performance, lightweight, and ideal for handling many concurrent connections

🌐 Setting Up an Apache Web Server

1️⃣ Install Apache

sudo apt update
sudo apt install apache2 -y

2️⃣ Start and Enable Apache

sudo systemctl start apache2
sudo systemctl enable apache2

3️⃣ Check Apache Status

sudo systemctl status apache2

4️⃣ Configure Apache Virtual Hosts (Multiple Sites on a Single Server)

Virtual Hosts allow multiple websites on a single server.

  • Create a configuration file for each site:
sudo nano /etc/apache2/sites-available/site1.conf
  • Add the following:
<VirtualHost *:80>
    ServerName site1.com
    DocumentRoot /var/www/site1
    <Directory /var/www/site1>
        AllowOverride All
    </Directory>
</VirtualHost>
  • Repeat for site2.com:
sudo nano /etc/apache2/sites-available/site2.conf
  • Enable both sites and restart Apache:
sudo a2ensite site1.conf
sudo a2ensite site2.conf
sudo systemctl restart apache2

🔑 SSL Offloading with Apache

SSL offloading is used to handle encryption/decryption at the reverse proxy level to reduce server load.

  • Install Certbot for SSL Certificates:
sudo apt install certbot python3-certbot-apache
  • Generate and Apply SSL Certificates:
sudo certbot --apache -d site1.com -d site2.com
  • Modify the Apache Virtual Host configuration to enable SSL termination:
sudo nano /etc/apache2/sites-available/site1-le-ssl.conf
  • Ensure the configuration contains:
<VirtualHost *:443>
    ServerName site1.com
    DocumentRoot /var/www/site1
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/site1.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/site1.com/privkey.pem
</VirtualHost>
  • Enable the SSL module and restart Apache:
sudo a2enmod ssl
sudo systemctl restart apache2
  • Auto-Renew SSL:
sudo certbot renew --dry-run

⚡ Setting Up an Nginx Web Server

1️⃣ Install Nginx

sudo apt update
sudo apt install nginx -y

2️⃣ Start and Enable Nginx

sudo systemctl start nginx
sudo systemctl enable nginx

3️⃣ Check Nginx Status

sudo systemctl status nginx

4️⃣ Configure Nginx Server Blocks (Multiple Sites on a Single Server)

  • Create a new configuration file for each site:
sudo nano /etc/nginx/sites-available/site1
  • Add the following content:
server {
    listen 80;
    server_name site1.com;
    root /var/www/site1;
    index index.html;
    location / {
        try_files $uri $uri/ =404;
    }
}
  • Repeat for site2.com:
sudo nano /etc/nginx/sites-available/site2
  • Enable both configurations and restart Nginx:
sudo ln -s /etc/nginx/sites-available/site1 /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/site2 /etc/nginx/sites-enabled/
sudo systemctl restart nginx

🔑 SSL Offloading with Nginx

SSL offloading is used to handle encryption/decryption at the reverse proxy level to reduce server load.

  • Install Certbot for SSL Certificates:
sudo apt install certbot python3-certbot-nginx
  • Generate and Apply SSL Certificates:
sudo certbot --nginx -d site1.com -d site2.com
  • Auto-Renew SSL:
sudo certbot renew --dry-run

📊 Monitoring Apache and Nginx with Grafana

1️⃣ Install Grafana

sudo apt update
sudo apt install -y grafana

2️⃣ Start and Enable Grafana

sudo systemctl start grafana-server
sudo systemctl enable grafana-server

3️⃣ Install and Configure Prometheus for Data Collection

sudo apt install prometheus -y

Modify /etc/prometheus/prometheus.yml and add:

scrape_configs:
  - job_name: 'apache'
    static_configs:
      - targets: ['localhost:9117']
  - job_name: 'nginx'
    static_configs:
      - targets: ['localhost:9113']

Restart Prometheus:

sudo systemctl restart prometheus

4️⃣ Install Exporters for Apache and Nginx

Apache Exporter:

sudo apt install prometheus-apache-exporter
sudo systemctl start prometheus-apache-exporter
sudo systemctl enable prometheus-apache-exporter

Nginx Exporter:

sudo apt install prometheus-nginx-exporter
sudo systemctl start prometheus-nginx-exporter
sudo systemctl enable prometheus-nginx-exporter

5️⃣ Add Prometheus as a Data Source in Grafana

  • Open Grafana at http://your_server_ip:3000
  • Login (default: admin/admin)
  • Navigate to Configuration -> Data Sources
  • Add a new Prometheus data source and enter http://localhost:9090

6️⃣ Create Dashboards for Monitoring

  • Go to Create -> Dashboard
  • Add a new panel
  • Use Prometheus queries like:
apache_requests_total
nginx_connections_active
  • Save and visualize Apache/Nginx performance!

✅ Conclusion

By following this guide, you now have a working web server setup using Apache or Nginx on Linux with SSL offloading. Understanding these configurations and security measures will help you deploy and manage web applications efficiently. 🚀

Would you like additional details on database integration or further security hardening? 🤔

Featured Articles

  • Insights into Royal Family Dynamics

    Insights into Royal Family Dynamics

    February 26, 2025
  • Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    February 26, 2025
  • North Korea Accused of Major Cyber Heist

    North Korea Accused of Major Cyber Heist

    February 26, 2025
  • Manchester United Announces Job Cuts Amid Financial Restructuring

    Manchester United Announces Job Cuts Amid Financial Restructuring

    February 26, 2025
  • Shannon Sharpe Criticizes Zion Williamson’s Fitness: A Deep Dive into the Controversy

    Shannon Sharpe Criticizes Zion Williamson’s Fitness: A Deep Dive into the Controversy

    February 26, 2025

Search

Author Details

Madhan Gopalakrishnan

I am a passionate “tech blogger” with a knack for breaking down complex topics into simple insights or exploring the latest trends in AI With 5 years of experience in IT Infra implementation and maintenance, I love to share knowledge through in-depth articles and practical tips. When not writing, you can find my hobby “traveling to offbeat destinations”.

  • X
  • Instagram
  • TikTok
  • Facebook

Follow Us on

  • Facebook
  • X
  • Instagram
  • VK
  • Pinterest
  • Last.fm
  • TikTok
  • Telegram
  • WhatsApp
  • RSS Feed

Categories

  • Article (15)
  • NEWS (73)

Archives

  • February 2025 (88)

Tags

About Us

Maalavs Magazine

It is your hub for the latest news across all domains, from technology and business to travel and innovation. We bring insightful updates, expert opinions, and engaging content to keep you informed and ahead. Whether you’re a tech enthusiast, a business professional, or a curious reader, we’ve got something for you. Stay updated with Maalavs Magazine!

Latest Articles

  • Insights into Royal Family Dynamics

    Insights into Royal Family Dynamics

    February 26, 2025
  • Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    February 26, 2025
  • North Korea Accused of Major Cyber Heist

    North Korea Accused of Major Cyber Heist

    February 26, 2025

Categories

  • Article (15)
  • NEWS (73)
  • Instagram
  • Facebook
  • LinkedIn
  • X
  • VK
  • TikTok

Proudly Powered by Maalavs | Maalavs Magazine

Scroll to Top