1080*80 ad

Installing Apache on Fedora 30

How to Install Apache on Fedora: A Step-by-Step Guide

The Apache HTTP Server, commonly known as Apache, is a free, open-source, and cross-platform web server that has powered a significant portion of the internet for decades. Renowned for its stability, rich feature set, and flexibility, it remains an excellent choice for hosting everything from simple static websites to complex, dynamic web applications.

This guide provides a comprehensive walkthrough for installing and configuring the Apache web server on a Fedora system. While the commands are shown for Fedora 30, the process remains largely identical for all modern Fedora releases.

Prerequisites

Before you begin, ensure you have the following:

  • A system running Fedora.
  • A user account with sudo or root privileges.
  • Access to the command line/terminal.

Step 1: Update System Packages

It is always a best practice to start by ensuring your system’s package repository is up to date. This guarantees you are installing the latest, most secure versions of the software.

Open your terminal and run the following command:

sudo dnf update

Press y and Enter if prompted to confirm the updates.

Step 2: Install the Apache Web Server

On Fedora and other RHEL-based distributions, the Apache software package is named httpd. To install it, use the dnf package manager.

Execute this command in your terminal:

sudo dnf install httpd

The system will calculate dependencies and ask for confirmation. Press y to proceed with the installation.

Step 3: Start and Enable the Apache Service

Once the installation is complete, the Apache service will not start automatically. You need to manage it using systemctl, the standard service manager for modern Linux systems.

First, start the Apache service for the current session:

sudo systemctl start httpd

Next, you should enable the service to start automatically on boot. This is a critical step for any server, ensuring your website comes back online after a reboot without manual intervention.

sudo systemctl enable httpd

To verify that the service is running correctly, you can check its status:

sudo systemctl status httpd

You should see an output indicating the service is active (running) in green text.

Step 4: Configure the Firewall to Allow Web Traffic

By default, Fedora’s built-in firewall will block external connections to the webserver. You must explicitly create rules to allow web traffic through. Web traffic uses port 80 for standard HTTP and port 443 for secure HTTPS.

Use the following firewall-cmd commands to permanently open these ports:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https

For the new rules to take effect, you must reload the firewall:

sudo firewall-cmd --reload

This firewall configuration is a crucial security step; without it, your web server will only be accessible from the machine it is running on.

Step 5: Verify Your Apache Installation

With Apache installed, running, and accessible through the firewall, it’s time to test it. You can do this by finding your server’s IP address.

Run one of the following commands to display your IP address:

hostname -I

or

ip a

Once you have your server’s IP address, open a web browser and navigate to http://your_server_ip.

If everything is configured correctly, you will be greeted by the Fedora Apache Test Page. This page confirms that your Apache web server is successfully installed and serving content.

Key Apache Files and Directories

Understanding where Apache stores its files is essential for managing your website. Here are the most important locations:

  • /etc/httpd/conf/httpd.conf: The main Apache server configuration file.
  • /etc/httpd/conf.d/: The directory for loading additional configuration modules and virtual host files.
  • /var/www/html: The default document root. This is where you should place your website’s HTML, CSS, and other files.
  • /var/log/httpd/: The location for Apache’s log files. The access_log and error_log are crucial for debugging.

Next Steps and Security Tips

You now have a functional web server. To build a production-ready website, consider the following actions:

  1. Set Up Virtual Hosts: To host multiple websites on a single server, you should configure Apache Virtual Hosts. This allows you to define separate document roots and configurations for each domain.
  2. Secure Your Server with HTTPS: In today’s web, SSL/TLS encryption is non-negotiable. Use Let’s Encrypt to obtain and install free SSL certificates, enabling secure HTTPS connections for your site.
  3. Harden Your Configuration: Review the httpd.conf file to disable unnecessary modules and tighten security settings, such as preventing directory listings and hiding the Apache version number.

By following these steps, you have successfully deployed a robust Apache web server on your Fedora system, creating a solid foundation for your web hosting needs.

Source: https://kifarunix.com/install-apache-on-fedora-30/

900*80 ad

      1080*80 ad