The name Apache has earned its spot in the web servers hall of fame because of its luring attributes that continue to make it a popular web server candidate around the globe.
These attributes include its open-source nature, its numerous and easy-to-configure features, and its large community support that make it easier for both newbie and elite users to debug configuration and performance issues related to Apache.
[ You might also like: How to Sync Two Web Servers in Linux Automatically ]
Linux distributions like Debian identify this web server as Apache2. However, crossing over to Linux distributions with RHEL footprints, this web server is identified as httpd. Fedora systems also identify Apache as httpd.
The Fedora community brags about this system’s dedication to only open-source software. Fedora is not only reliable and stable but also a platform for many education software. One such educational software is Apache.
Understanding the Ins and Outs of this webserver software can transform you from a student to a master in terms of handling and configuring web application projects. This article guide will take you through installing Apache on Fedora and getting started with it.
Install Apache in Fedora
Adhere to the following installation steps to get Apache up and running on your Fedora system. Also, make sure you are a root user or you have root privileges (Sudoer user) on the Fedora system you are using.
First, your Fedora system needs to be up-to-date with the latest software patches and fixes.
$ sudo dnf update
To install Apache on Fedora, execute the following command on your terminal.
$ sudo dnf install httpd
By default, Apache should already be up and running on your Fedora system. However, if you restart or shut down your system, Apache might become inactive unless you start it again.
To deal with this hurdle, we will restart and enable Apache so that even after your system restarts or shuts down, powering it back on will automatically launch and run Apache.
$ sudo systemctl start httpd $ sudo systemctl enable httpd
The next step is to confirm the status of the Apache service.
$ sudo systemctl status httpd
Other useful Apache commands to consider include the following:
$ sudo systemctl stop httpd $ sudo systemctl restart httpd $ sudo systemctl reload httpd
Apache uses port 80 for HTTP access and port 443 for HTTPS access. The Fedora system’s firewall needs to permit these ports the needed access to the outside world so that other client computers can access we apps hosted by Apache on this Fedora system.
To grant Apache Access through the firewall, execute the following commands:
$ sudo firewall-cmd --permanent --add-service=http $ sudo firewall-cmd --permanent --add-service=https $ sudo firewall-cmd --reload
Now that we have installed Apache and achieved the needed configurations to give it access to other client computers, it is time to test its responsiveness on a web browser.
http://localhost or http://127.0.0.1
Hosting a Website with Apache in Fedora
The default configuration of Apache is enough to host a single website, but for multi-domain hosting, you need to use the Apache Virtual Hosts directive feature.
For example, to host another website domain called ‘linuxshelltips.in‘, you need to set up a separate virtual host configuration as shown.
$ sudo mkdir -p /var/www/linuxshelltips.in/html $ sudo mkdir -p /var/www/linuxshelltips.in/log $ sudo chown -R $USER:$USER /var/www/linuxshelltips.in/html $ sudo chmod -R 755 /var/www
Next, create a sample index.html page to check the new site.
$ sudo vi /var/www/linuxshelltips.in/html/index.html
Add the following HTML code.
<!DOCTYPE html> <html> <head> <title>Welcome to linuxshelltips.i</title> </head> <body> <h1>LinuxShellTips Introduces linuxshelltips.in</h1> <p>You have successfully accessed linuxshelltips.in home page!</p> </body> </html>
Creating Apache Virtual Host in Fedora
Now create domain virtual host directories called sites-available and sites-enabled for storing the virtual host configuration files.
$ sudo mkdir /etc/httpd/sites-available $ sudo mkdir /etc/httpd/sites-enabled
Next, define the sites-enabled directory location in the main Apache configuration file.
$ sudo vi /etc/httpd/conf/httpd.conf
In the end, add the following line and close the file.
Finally, create a domain
linuxshelltips.in virtual host file.
$ sudo vi /etc/httpd/sites-available/linuxshelltips.in
Next, add the following virtual host configuration with the domain name you are using.
<VirtualHost *:80> ServerAdmin www.linuxshelltips.in ServerAlias linuxshelltips.in DocumentRoot /var/www/linuxshelltips.in/html ErrorLog /var/www/linuxshelltips.in/log/error.log CustomLog /var/www/linuxshelltips.in/log/access.log combined </VirtualHost>
Save the file and close the terminal editor.
To active our virtual host file, you need to create a symbolic link between the sites-available and the sites-enabled directories.
$ sudo ln -s /etc/httpd/sites-available/linuxshelltips.in /etc/httpd/sites-enabled/linuxshelltips.in.conf
Finally, restart the Apache and make sure it is running.
$ sudo systemctl restart httpd $ sudo systemctl status httpd
Now you should be able to see the hosted index.html page through your domain name.
Enable HTTPS for Apache in Fedora
To enable HTTPS on Apache, you need to install Certbot and mod_ssl packages from the EPEL repo.
$ sudo dnf install epel-release $ sudo dnf install certbot python3-certbot-apache mod_ssl
Once Certbot is installed, you can obtain a free SSL certificate for our domain under /etc/letsencrypt/live directory.
$ sudo certbot --apache -d linuxshelltips.in
Once you obtain a certificate for your domain, you can verify the SSL certificate at the following URL.
The reputation of Apache speaks for itself. We can never run out of praises for its contribution to web-based projects. With Fedora continuously prioritizing open-source projects, the sky is the limit for students and masters of the website administration.