This step-by-step guide will walk you through how to install Apache HTTPD on Fedora, transforming your system into a high-performance web server. Specifically designed for Linux enthusiasts, developers, and system administrators, this tutorial provides practical insights to boost your server’s security, speed, and reliability.
In this guide, you will learn to leverage Fedora’s powerful DNF package manager to update your system, install Apache, and master essential configurations. Therefore, follow these clear instructions and expert strategies to elevate your Fedora web server setup and maintain peak performance when you install Apache HTTPD on Fedora.
Install Apache HTTPD on Fedora: Update Fedora Packages First
Firstly, updating your Fedora system ensures that it runs the latest software, which is essential for compatibility and security. Indeed, before installing new software, it is always a good practice to ensure your system is current.
Next, open your terminal and run the command below to update your packages:
sudo dnf upgrade --refresh
This command uses sudo
for administrative rights and dnf upgrade
to update all packages. Furthermore, the --refresh
option ensures you are getting the latest information from your repositories. It is important to let this process complete before moving to the next step to maintain system integrity and smooth functioning. Consequently, once your system is updated, you can proceed with the Apache installation, a key part of learning to install Apache HTTPD on Fedora.
Install Apache HTTPD on Fedora via DNF Command
With your system up to date, installing Apache (also known as httpd) is straightforward using Fedora’s DNF package manager. In fact, you can install Apache with a single command.
In your terminal, run the following command:
sudo dnf install httpd
This command fetches and installs Apache on your Fedora system. DNF handles all necessary dependencies and initial configurations, thereby simplifying the installation. The process is usually quick, leaving Apache ready for use upon completion.
After you install Apache HTTPD on Fedora, it’s important to verify the installation and ensure the service is running as expected. This helps confirm that your Fedora system is ready to serve web content. Subsequently, let’s enable and start the Apache service.
Enable Apache (HTTPD) Service after you Install Apache HTTPD on Fedora
Once Apache is installed, the next crucial step is to start and enable the httpd service to ensure it runs on system boot. For instance, if it wasn’t automatically activated during installation, use these commands:
sudo systemctl start httpd
sudo systemctl enable httpd
Here, sudo systemctl start httpd
begins the Apache service, and sudo systemctl enable httpd
sets it to launch at boot. This two-step approach ensures Apache is active and persistently available. Alternatively, you can combine these steps for efficiency.
Alternatively, you can combine these steps:
sudo systemctl enable httpd --now
The --now
flag with sudo systemctl enable httpd
starts Apache immediately while also configuring it to launch at boot, thus streamlining the process. As a result, Apache will always be available after a reboot.
Verify Apache (HTTPD) Service Status when you Install Apache HTTPD on Fedora
Next, it’s important to verify Apache’s status to ensure everything is running smoothly:
systemctl status httpd

This command provides Apache’s operational status. The output includes the service’s current state (e.g., active (running)) and any recent log messages, which are essential for troubleshooting. Regularly checking the status can help maintain a stable and functional Apache setup on your Fedora system. Therefore, if you see any issues, address them before moving forward.
Configure Firewalld After You Install Apache HTTPD on Fedora
Allowing Web Traffic Through Firewalld when you Install Apache HTTPD on Fedora
After installing Apache (HTTPD) on Fedora, it is essential to configure Firewalld to allow traffic on ports 80 (HTTP) and 443 (HTTPS). These steps are vital for the security and accessibility of your web server. Indeed, without proper firewall configuration, your server may not be reachable from the internet.
Opening Port 80 (HTTP):
Execute the following command to open port 80, which is used for HTTP traffic:
sudo firewall-cmd --permanent --add-port=80/tcp
This command configures Firewalld to permanently allow incoming TCP traffic on port 80. Following this, you should open port 443 for HTTPS.
Opening Port 443 (HTTPS):
To allow secure, encrypted traffic, open port 443 with this command:
sudo firewall-cmd --permanent --add-port=443/tcp
Port 443 is used for HTTPS traffic, providing encrypted communication between clients and the server. Once both ports are open, reload the firewall to apply the changes.
Applying the Firewall Changes:
After setting the rules, apply them by reloading Firewalld:
sudo firewall-cmd --reload
Reloading the firewall ensures that all changes are active and effective immediately. Consequently, your server is now ready to accept web traffic on both HTTP and HTTPS.
Security Considerations for Firewall Rules
Understanding the security implications of these changes is crucial. Specifically, opening only necessary ports like 80 and 443 minimizes potential vulnerabilities, safeguarding your server from unauthorized access and threats. Therefore, always review your firewall settings carefully after making changes.
Verifying Apache Accessibility via Web Browser after you Install Apache HTTPD on Fedora
To confirm successful configuration, access the Apache (HTTPD) default landing page:
- Open your web browser.
- Navigate to
http://localhost
orhttp://<your_server_ip>
.
If configured correctly, the Apache default page should appear, confirming the server’s operational status. Otherwise, revisit the previous steps to troubleshoot any issues.

Troubleshooting Apache Post-Installation on Fedora
If you encounter issues after you install Apache HTTPD on Fedora, such as the service not starting or web pages not loading, common areas to check include your Firewalld settings, SELinux status, and Apache’s configuration files (typically in /etc/httpd/conf/
and /etc/httpd/conf.d/
).
SELinux Troubleshooting Tip for Apache on Fedora
Note: Temporarily setting SELinux to permissive mode with sudo setenforce 0
can help diagnose if SELinux is blocking Apache. However, this is for troubleshooting only. Importantly, always return SELinux to enforcing mode (sudo setenforce 1
) after resolving issues to maintain system security. Leaving SELinux permissive can leave your system vulnerable. This is a useful tip when you install Apache HTTPD on Fedora and run into access issues.
Create a Virtual Host After Installing Apache HTTPD on Fedora
Step 1: Create and Configure Website Directories
Start by creating a directory for your virtual host on Fedora Linux. This directory will act as the document root for your website’s files. For example, for a domain like example.com, use the following command:
sudo mkdir /var/www/example.com
Replace example.com
with your actual domain name. This directory (/var/www/example.com
) will hold all website files, including HTML, images, and scripts. For organizational and security purposes, creating separate directories for different virtual hosts is advisable. Next, you need to set the directory’s ownership and permissions.
Then, set the directory’s ownership and permissions so that Apache can access it:
sudo chown -R apache:apache /var/www/example.com
sudo chmod -R 755 /var/www/example.com
The first command changes the directory ownership to the apache user and group, and the second sets the necessary permissions (read, write, execute for owner; read and execute for group and others). With these steps complete, you can now create your website’s index file.
After that, create an index.html
file in this directory (e.g., /var/www/example.com/index.html
). This file is typically the first page visitors see. Use a text editor like Nano to create this file:
sudo nano /var/www/example.com/index.html
Inside the editor, you can add the following sample HTML structure:
<html>
<head>
<title>Welcome to example.com</title>
</head>
<body>
<h1>Welcome to Example Domain</h1>
<p>This is a sample page for the domain example.com.</p>
</body>
</html>
Customize this HTML to fit your site’s needs. Save and exit the editor (in Nano, this is typically Ctrl + X, then Y to confirm, then Enter). Afterward, you are ready to configure your virtual host.
Step 2: Configure Apache for Virtual Hosts
A. Set Up Virtual Host Directories in Apache Configuration
First, create the sites-available
and sites-enabled
directories within Apache’s configuration path. These directories help organize your virtual host configuration files:
sudo mkdir /etc/httpd/sites-available /etc/httpd/sites-enabled
Next, instruct Apache to look for virtual host configurations in the sites-enabled
directory. To do this, edit the main Apache configuration file (httpd.conf
):
sudo nano /etc/httpd/conf/httpd.conf
At the end of the file, add the following line to include configurations from any .conf
files within sites-enabled
:
# IncludeOptional conf.d/*.conf (this line might already exist)
IncludeOptional sites-enabled/*.conf
Save and exit the file (Ctrl + O to write out, Ctrl + X to exit in Nano). Once this is done, you can proceed to create your specific virtual host configuration file.

B. Create the Virtual Host Configuration File
Now, create a new configuration file for your domain (e.g., example.com.conf
) inside the /etc/httpd/sites-available/
directory:
sudo nano /etc/httpd/sites-available/example.com.conf
In the file, add the following basic virtual host configuration. Remember to adjust ServerName
, ServerAlias
, and DocumentRoot
as needed for your domain and directory structure:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/
ErrorLog /var/log/httpd/example.com-error.log
CustomLog /var/log/httpd/example.com-access.log combined
</VirtualHost>
C. Grant Apache Access to the Document Root
To allow Apache to serve files from your new document root (/var/www/example.com/
) and ensure public access, you need to add a <Directory>
block. You can place this in your main Apache configuration (/etc/httpd/conf/httpd.conf
) or, preferably, within your virtual host file (/etc/httpd/sites-available/example.com.conf
) for better organization. If adding to httpd.conf
, append these lines:
<Directory /var/www/example.com/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Alternatively, if you add this to your example.com.conf
file, it would look like this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/
ErrorLog /var/log/httpd/example.com-error.log
CustomLog /var/log/httpd/example.com-access.log combined
<Directory /var/www/example.com/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Save and exit the configuration file. This setup ensures your site will be accessible to the public.
Step 3: Enable the Virtual Host for Apache on Fedora
After creating the virtual host configuration file (e.g., example.com.conf
in /etc/httpd/sites-available/
), you need to enable it. To do so, create a symbolic link (symlink) from your configuration file in sites-available
to the sites-enabled
directory:
sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/
Finally, restart Apache to apply all the configuration changes. This step is necessary for your new virtual host to become active:
sudo systemctl restart httpd
After restarting Apache, visit http://example.com
(or your actual domain) in your web browser. If you haven’t configured DNS for your domain yet, and you’re testing locally, you might need to edit your local /etc/hosts
file or use the server’s IP address if configured appropriately for direct IP access to the virtual host (though domain-based virtual hosts are standard). You should see the index.html
landing page you created earlier. If not, double-check your configuration files for typos or errors, and review Apache’s error logs (/var/log/httpd/error_log
or your custom virtual host error log).

Manage Apache HTTPD Service on Fedora
Understanding Apache Server Logs when you Install Apache HTTPD on Fedora
Apache server logs are crucial for monitoring server activity and troubleshooting issues. By default on Fedora, Apache’s main logs are typically located in /var/log/httpd/
. The standard filenames are access_log
for access logs (records of all requests processed by the server) and error_log
for error logs (records of errors Apache encountered). However, as shown in the virtual host example, you can (and should) customize these log filenames on a per-virtual-host basis (e.g., example.com-access.log
, example.com-error.log
). Reviewing these logs regularly helps you quickly identify and resolve potential problems.
Example: Custom Log Filenames in Virtual Host
To change the log filenames for a specific virtual host, you edit its configuration file (e.g., /etc/httpd/sites-available/example.com.conf
). For instance, here’s how you would define custom log names within the <VirtualHost>
block:
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/example.com
# Custom log file names for this virtual host
CustomLog /var/log/httpd/www.example.com-access.log combined
ErrorLog /var/log/httpd/www.example.com-error.log
</VirtualHost>
This configuration directs access logs to www.example.com-access.log
and error logs to www.example.com-error.log
within the /var/log/httpd/
directory. Remember to provide the full, correct file path. After making such changes, always restart Apache (sudo systemctl restart httpd
) to apply them.
Essential Apache Service Management Commands
Managing the Apache service (httpd) involves a set of systemctl
commands that allow you to control its operation. With these commands, you can start, stop, restart, or reload Apache as needed.
Stopping Apache:
To stop the Apache server, use:
sudo systemctl stop httpd
This command halts the Apache service. You should use this when you need to perform maintenance or updates that require the server to be offline.
Starting Apache:
To start the Apache server if it is stopped, use:
sudo systemctl start httpd
This command activates the Apache service, making it ready to serve web content.
Restarting Apache:
To stop and then start the Apache server (a full restart), use:
sudo systemctl restart httpd
Restarting is necessary for most configuration changes to take effect or to recover from certain errors. Generally, you should restart Apache after making significant modifications.
Reloading Apache:
To apply configuration changes gracefully without dropping active connections, use:
sudo systemctl reload httpd
Reloading applies many configuration changes without disrupting the running service. This is often preferred over a restart for minor updates if supported by the changes made.
Disabling Apache on Boot:
To prevent Apache from starting automatically when the system boots, use:
sudo systemctl disable httpd
This command removes Apache from the list of services that start on system boot. Use this if you want to manually control when Apache runs.
Enabling Apache on Boot:
To set Apache to start automatically when the system boots (if previously disabled), use:
sudo systemctl enable httpd
This ensures that Apache starts whenever the system boots up, providing consistent web service availability. As a result, your website will typically always be accessible after a reboot.
Secure Apache with Let’s Encrypt SSL Free Certificate after you Install Apache HTTPD on Fedora
Install Certbot for SSL/TLS Certificate Automation
First, begin by installing Certbot, a tool for automating the acquisition and renewal of SSL/TLS certificates, thereby ensuring HTTPS encryption for your website. To install Certbot, execute the following command:
sudo dnf install certbot python3-certbot-apache
Generate SSL/TLS Certificate for Your Domain
After installation, generate an SSL/TLS certificate for your domain with this command:
sudo certbot --apache -d example.com
Replace “example.com” with your actual domain name. Once the certificate is generated, you can then proceed to configure Apache to use it.
Alternative Command for Generating SSL Certificate
For a comprehensive SSL setup, consider using the following command:
sudo certbot --dry-run --apache --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d www.example.com
- –dry-run: Tests the certificate generation without altering the system.
- –apache: Indicates the certificate is for an Apache server.
- –agree-tos: Agrees to Let’s Encrypt’s terms of service.
- –redirect: Redirects HTTP traffic to HTTPS.
- –hsts: Enables HTTP Strict Transport Security, ensuring only secure HTTPS connections.
- –staple-ocsp: Activates OCSP stapling for verifying the SSL certificate.
- –email: Your email address associated with the certificate.
- -d: The domain name for the certificate, here “www.example.com”.
Configuring Apache to Use the SSL Certificate after you Install Apache HTTPD on Fedora
To configure Apache, open the SSL configuration file as shown below:
sudo nano /etc/httpd/conf.d/ssl.conf
In this file, add the following lines, replacing “example.com” with your domain. This will enable SSL for your website:
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
Verifying and Renewing the SSL Certificate
Post-installation, your website will transition from “HTTP://www.example.com” to “HTTPS://www.example.com,” ensuring encrypted and secure communication. However, to keep your certificate valid, you need to renew it regularly.
Setting Up Automatic Certificate Renewal
To keep the SSL certificate updated, set up a cron job for Certbot renewal. First, however, test the renewal process to ensure it works as expected:
sudo systemctl restart httpd
This test ensures the renewal script functions correctly before scheduling it as a cron job. If the test passes, you can then automate the process.
sudo certbot renew --dry-run
SSL Certificate Renewal and Management
Verifying SSL Certificate Status
Before automating the renewal process, it’s crucial to understand the current status of your SSL certificates. To check the status, including the expiration dates of all certificates managed by Certbot, use this command:
sudo certbot certificates
This command provides a list of all SSL certificates handled by Certbot, along with their respective expiration dates. This information is essential to confirm that your certificates are active and to understand when they will require renewal. Once you know the status, you can proceed to automate renewals.
Automating SSL Certificate Renewal
To ensure uninterrupted HTTPS service, SSL certificates must be renewed periodically. Automating this process is vital for maintaining a secure website. Fortunately, Certbot makes this easy.
Installing Cronie for Cron Jobs
If Cronie, the cron job manager, is not installed on your Fedora system, install it using the following command:
sudo crontab -e
Cronie allows you to schedule tasks like the Certbot renewal script to run at specified times and intervals. After installing Cronie, you can edit your cron jobs.
Editing Cron Job Configuration
After installing Cronie, schedule the SSL certificate renewal by editing the cron job configuration as shown below:
sudo dnf install cronie
This command opens the crontab editor, where you can add scheduled tasks. Once open, you can add the renewal job.
Scheduling the Renewal Job
Within the crontab editor, add the following line to schedule the renewal command to run twice daily:
0 6,18 * * * certbot renew --quiet
This cron job is set to run the certbot renew command at 6:00 AM and 6:00 PM every day. Furthermore, the –quiet option ensures that Certbot runs silently without generating unnecessary output. As a result, your certificates will always be up to date.
Understanding Certbot’s Renewal Process
Certbot intelligently manages the renewal process. For instance, it only attempts to renew certificates that are within 30 days of expiration. If a certificate does not need renewal, Certbot will not perform any action. This efficiency ensures your server is not burdened with unnecessary processes and that your SSL certificates are always up to date. Therefore, you can rest assured that your site remains secure.
Setting up this automated renewal process is a best practice for maintaining continuous HTTPS encryption, ensuring your website remains secure and trusted by users and search engines. In summary, automation saves time and reduces the risk of certificate expiration.
Maintenance & Cleanup for your Apache HTTPD Fedora Installation
Secure Directories and Files on Apache on Fedora
Moreover, ensuring the security of your server involves setting appropriate permissions for files and directories. Overly permissive settings can expose your server to risks. Therefore, always use the least permissive settings necessary for your application to function.
Setting Secure Permissions
For directories and files under /var/www/example.com/, use these commands:
sudo find /var/www/example.com/ -type d -exec chmod 755 "{}" \;
sudo find /var/www/example.com/ -type f -exec chmod 644 "{}" \;
These commands set directories to 755 (read, write, execute for the owner, and read and execute for others) and files to 644 (read and write for the owner, read for others), which are standard secure permissions. By following these steps, you significantly reduce the risk of unauthorized access.
Special Permissions for Specific Applications
Note that some applications, like phpBB, may require 777 permissions on certain folders. Always adjust permissions based on application requirements. However, it’s crucial to avoid using 777 unless absolutely necessary.
Comprehensive Security Approach
Remember, setting permissions is just one aspect of security. Implementing SSL certificates and proper firewall configurations are also crucial for robust server protection. Altogether, these measures help keep your server safe.
Update Apache HTTPD After Installation on Fedora
Moreover, keeping Apache up to date is crucial for security and performance. Therefore, make it a habit to check for updates regularly for your Apache HTTPD Fedora setup.
Updating Apache
To update Apache, along with other system packages, use the following command:
sudo dnf update --refresh
This command refreshes the package database and updates all installed packages, including Apache. After updating, it’s wise to always test your configuration to ensure everything works as expected.
Uninstall Apache HTTPD from Fedora
Conversely, in scenarios where Apache needs to be removed from the system, follow these steps to ensure a clean uninstallation. Removing Apache HTTPD from Fedora is straightforward.
Disabling and Stopping Apache
First, disable and stop the Apache service as shown below:
sudo systemctl disable httpd --now
This command stops the Apache service and prevents it from starting automatically at boot. Next, you can remove the package.
Uninstalling Apache
To remove Apache from your system, execute the following command:
sudo dnf remove httpd
This command uninstalls the Apache package. Afterward, you should clean up any leftover files.
Cleaning Up Leftover Files
After uninstallation, remove any residual files in the Apache configuration directory:
sudo rm -R /etc/httpd/
This step ensures that all Apache-related files are completely removed from your system. As a result, your Fedora installation will be free of Apache components.
Additional Resources & Examples for Apache HTTPD on Fedora
Quick Reference Table for Apache HTTPD on Fedora
Action | Command |
---|---|
Update system packages | sudo dnf upgrade --refresh |
Install Apache | sudo dnf install httpd |
Start Apache | sudo systemctl start httpd |
Enable Apache on boot | sudo systemctl enable httpd |
Check Apache status | systemctl status httpd |
Restart Apache | sudo systemctl restart httpd |
Reload Apache config | sudo systemctl reload httpd |
Stop Apache | sudo systemctl stop httpd |
Disable Apache on boot | sudo systemctl disable httpd |
Test Apache config | sudo apachectl configtest |
View error log | sudo tail -f /var/log/httpd/error.log |
Real-World Configuration Examples for Apache HTTPD on Fedora
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
Custom Error Pages
ErrorDocument 404 /custom_404.html
ErrorDocument 500 /custom_500.html
Password Protect a Directory
<Directory /var/www/example.com/secure>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
Create the password file with: sudo htpasswd -c /etc/httpd/.htpasswd username
Advanced Tips for your Apache HTTPD Fedora Installation
To get the most out of your decision to install Apache HTTPD on Fedora, explore advanced modules, performance tuning, and security best practices. Fedora’s integration with Apache makes it easy to expand your web server’s capabilities as your needs grow. Indeed, as you gain experience, you can further optimize your setup.
Best Practices & Reminders for Apache HTTPD on Fedora
- Back up configs and web data before making major changes: For instance,
sudo cp -a /etc/httpd /etc/httpd.bak
andsudo cp -a /var/www /var/www.bak
- Keep Apache and your system updated for security and stability.
- Minimize enabled modules to reduce attack surface.
- Use strong permissions and avoid 777 except where absolutely required (and never on config files).
- Regularly monitor logs for unusual activity or errors.
- Test configuration changes with
sudo apachectl configtest
before restarting Apache.
Conclusion on How to Install Apache HTTPD on Fedora
In conclusion, by following these steps, you’ve successfully set up Apache HTTPD on Fedora Linux—a foundation trusted by millions worldwide. With your server up and running, you’re now equipped to host anything from simple static pages to complex web applications. However, don’t stop here: explore Apache’s extensive modules, fine-tune your configuration, and join the vibrant Linux and open-source community. If you found this guide helpful or have tips of your own, please share your experience and help others on their Fedora journey! Ultimately, your journey with Apache on Fedora is just beginning, and there is always more to learn.