Apache web server setup on Ubuntu

2023-10-24

Introduction:

This document outlines the steps required to set up an Apache web service on an Ubuntu server using iptables for firewall configuration. Apache is one of the most popular web servers widely used for hosting websites.

Prerequisites

Before you begin, ensure you have the following:

  • An Ubuntu server with root access or a user with sudo privileges.
  • An active internet connection.

Steps

1. Update the System

Before installing Apache, make sure your system is up to date. Run the following commands:

sudo apt update
sudo apt upgrade

2. Install Apache

Install the Apache web server using the following command:

sudo apt install apache2

3. Start the Apache Service

After installation, start the Apache service and enable it to start automatically on system boot:

sudo systemctl start apache2
sudo systemctl enable apache2

4. Configure iptables Firewall

Use iptables to allow incoming traffic on port 80 for Apache:

sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo netfilter-persistent save

5. Verify the Installation

Open a web browser and navigate to your server’s IP address. You should see the default Apache page, indicating that the server is running correctly. Conclusion

Congratulations! You have successfully set up an Apache web service on your Ubuntu server with iptables for firewall configuration. You can now start deploying your web applications or configure virtual hosts based on your needs.

Make sure to check the official Apache documentation for advanced configurations and customization options: Apache Documentation.