e Learning

How to Install Apache on Fedora Server

In this tutorial we are going to learn how to install and configure Apache HTTPD Server on Fedora Server. I will also explain how to create Apache Virtual Host on Fedora HTTPD Server to host more than one website on the Web Server.

For This tutorial I am using Fedora Server 24, But you can do this on Fedora Workstation and also in any Previous Version of Fedora Linux.

  1. Install Apache on Fedora Server.
  2. Configure Fedora Firewall.
  3. Create Virtual Host on Fedora HTTPD Server.

Install Apache on Fedora Server

The Apache Web Server for Fedora Provides by the httpd package. We can install httpd on Fedora using dnf install command. Open the Linux terminal and execute,

dnf install httpd

After the installation is finished, start and enable Apache on Fedora using systemctl command.

systemctl start httpd

systemctl enable httpd

Configure Fedora Firewall for http Traffic

Next, we need to configure fedora firewall to allow http requests to the our web server.

firewall-cmd –permanent –add-service=http

firewall-cmd –permanent –add-service=https

firewall-cmd –reload

Test Apache Web Server

To test the apache web server, try to access localhost using curl command.

curl http://localhost

Also, From a Remote Computer, Open Web browser and type the IP Address of your Fedora Server on the Address bar. If the installation is successful, you should get the Fedora Test Page for Apache HTTPD Server.

How to Install Apache on Fedora Server

Default Document Root for the Apache Server is /var/www/html folder. Now you can host your static website by putting the content of your website to /var/www/html folder.

Create Apache Virtual Host on Fedora Server

To Configure a Virtual Host first we need to create a configuration file for the Virtual Host inside the ls /etc/httpd/conf.d/ directory with .conf extension.

For example, If your domain name is www.example.com, then the configuration file should be something like example.conf.

Create the Configuration File.

vim /etc/httpd/conf.d/example.conf

Add Virtual host configuration

Then, we need to add the Virtual Host block to the Configuration File. Following is the sample Virtual host configuration.

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example/
    RewriteEngine On
    ErrorLog "logs/example.com.error_log"
    CustomLog "logs/example.com.access_log" combined
    <Directory /var/www/example/>
        AllowOverRide All
        Require all granted

Create the Document Root

The Document root is the folder where we put the content of our website.

sudo mkdir /var/www/example

sudo chgrp apache /var/www/example

sudo chmod 750 /var/www/example

Finally, we need to restart the Apache Web Server.

systemctl restart httpd

This way you can host as many websites as you want in your Fedora Web Server.

Summary – Install Apache on Fedora Server

In this tutorial we learned how to install and configure Apache on Fedora Server.