One of the most common uses for any Linux system is as a web server. By far the most prevalent and famous web server is Apache. Apache is readily available in Fedora in pre-packaged form. You can use it to host content and applications for free anywhere you have a server.
First, install the software packages for the Apache server. The recommended way to install the server is in a group of related packages.
su -c 'dnf group install "Web Server"'
This command installs the entire Web Server package group. The group includes other commonly used tools such as:
- PHP and Perl support
- The squid caching proxy
- Traffic analysis tools
If for some reason you don’t want these helpful packages, you can install the web server by itself. Use this command:
su -c 'dnf install httpd'
The web server package, httpd, depends on some other packages. They must be installed for the web server to function. This command installs those dependencies.
Configuring the system
Next, you may need to configure the system so other computers can contact the web server. You can skip this step if you only want to test a web server on the same computer you’re on.
Fedora systems have a protective firewall by default. Therefore, you must open specific service ports in that firewall to let other computers connect. To open the specific firewall ports for the web server, run these commands:
su -c 'firewall-cmd --add-service=http --add-service=https --permanent' su -c 'firewall-cmd --reload'
The two service ports opened are:
- http — Port 80, used for standard, non-secure web communications
- https — Port 443, used for secure web communications
Also note the reload command makes these services active. Therefore, if you haven’t made other firewall changes permanent, those changes are lost when you reload. If you only want to open these services temporarily, use this command:
su -c 'firewall-cmd --add-service=http --add-service=https'
Testing the web server
Open a web browser on your system. Go to http://localhost and a web page like this appears:
This page confirms your web server is running correctly.
The next steps are entirely up to you. Here is one article with ideas for what to do with your new web server.