FedoraRHEL Based

How To Install Apache on Fedora 39

Install Apache on Fedora 39

In this tutorial, we will show you how to install Apache on Fedora 39. Apache, a robust and widely used web server, is an essential component for hosting websites and applications. This comprehensive guide is tailored for Fedora 39 users who seek a manual, step-by-step approach to installing Apache, configuring virtual hosts, and setting up a secure firewall using CLI.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Apache web server on a Fedora 39.

Prerequisites

Before diving into the installation process, let’s ensure that you have everything you need:

  • A server running one of the following operating systems: Fedora 39.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You’ll need an active internet connection to download Apache and its dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Apache on Fedora 39

Step 1. Before any installation, ensure your package repository is up to date. Use the command:

sudo dnf clean all
sudo dnf update

Step 2. Installing Apache on Fedora 39.

Apache is readily available in the default Fedora repository. Let’s install it using the DNF package manager:

sudo dnf install httpd

Once installed, start and enable Apache:

sudo systemctl start httpd
sudo systemctl enable httpd

To verify the installation, open your web browser and enter your server’s IP address. You should see the default Apache welcome page.

Step 3. Configuring Virtual Hosts.

Virtual Hosts allow you to host multiple websites on a single server. Here’s a step-by-step guide to configuring Virtual Hosts on Apache:

Create a directory for each of your websites:

sudo mkdir -p /var/www/html/website1
sudo mkdir -p /var/www/html/website2

Navigate to the Apache configuration directory and create a new configuration file for each website:

sudo nano /etc/httpd/conf.d/website1.conf

Add the following configuration:

<VirtualHost *:80>
ServerAdmin webmaster@website1
DocumentRoot /var/www/html/website1
ServerName website1.com
ErrorLog /var/log/httpd/website1_error.log
CustomLog /var/log/httpd/website1_access.log combined
</VirtualHost>

Save the file and repeat the process for other websites.

Edit the main Apache configuration file to include your Virtual Hosts:

sudo nano /etc/httpd/conf/httpd.conf

Add the following line at the end:

IncludeOptional conf.d/*.conf

Save the file, then restart Apache to apply the changes:

sudo systemctl restart httpd

Now, you can access your websites by entering their respective domain names in your browser.

Step 4. Firewall Setup for Apache.

Firewalld is the default firewall management tool on Fedora 39. Let’s configure it to allow traffic on the default HTTP port:

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

Check the status to ensure the changes are applied:

sudo firewall-cmd --list-all

Step 4. Troubleshooting and Common Issues.

Encountering issues is common in the world of system administration. Here are some tips to troubleshoot common Apache issues:

  • Checking Apache Error LogsApache logs provide valuable information. Check the error logs for any issues:
sudo tail -f /var/log/httpd/error_log
  • Debugging Common Installation and Configuration Issues

    Community support forums like Stack Overflow and the Fedora community forums are excellent resources for finding solutions to common problems.

Step 5. Best Practices and Optimization.

Ensure your Apache server performs optimally with these best practices:

  • Fine-Tuning Apache Performance

Adjust Apache’s configuration settings for optimal performance:

sudo nano /etc/httpd/conf/httpd.conf

Tweak settings like MaxRequestWorkers, MaxConnectionsPerChild, and KeepAliveTimeout.

  • Resource Allocation and Optimization Tips

    Allocate sufficient resources to your server. Optimize images and use caching mechanisms to improve website loading times.

  • Periodic Maintenance and UpdatesRegularly update your server software and check for security vulnerabilities.

Congratulations! You have successfully installed Apache. Thanks for using this tutorial for installing the Apache HTTP server on your Fedora 39 system. For additional Apache or useful information, we recommend you check the official Apache website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button