Tech Junkie Blog - Real World Tutorials, Happy Coding!: Linux: Installing Apache Web Server

Monday, July 26, 2021

Linux: Installing Apache Web Server

 In this post we are going to install the Apache Web Server, which is the most common web server in the world.  With a web server you can serve up web sites or business products on the web.  Therefore it's kind of like giving your Linux system a purpose to exist.

The service you have to install is called httpd and the configuration files are located in the following directories

  • /etc/httpd/conf/httpd.conf
  • /var/www/html/index.html
And the log files are in /var/log/httpd

Here are the steps to install the Apache Web Server:

1. So first let's install the service, you can do this by typing the command dnf install httpd -y



















2.  In the /etc/httpd/conf/httpd.conf file you will see that the ServerRoot points to the folder /etc/httpd and it's listening to port 80 because of the line that says Listen 80, you can change the directory for the ServerRoot and Listen properties in the configuration file to change the directory and the port respectively.  Another important setting is the DocumentRoot setting, this property defines your website's homepage or the starting point.  Since the DocumentRoot points to the directory /var/www/html let's navigate to the directory and see if there's an index.html page in the directory

3. If you don't have an index.html page in the directory, t's easy enough to create one.  Just type vi index.html in the directory and paste the following code in the file to get a simple html page.  But for the most part you will have the default Apache index.html page and that's perfectly fine we just want to see that it works at the end of this lesson.

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p>Hello Apache!</p>
</body>
</html>


4. Now that we have everything in place we want to start the service and enable it so that it starts on boot up with the following commands in order
  1. systemctl start httpd
  2. systemctl enable httpd
5.  To view the web page you typing ifconfig to see the server's IP address


6. To view the web page you can just type in the IP address in the browser's address bar. If you can't view the page, type stopping the firewall with the command systemctl stop firewalld















No comments:

Post a Comment

Search This Blog