Install Apache Server on CentOS

A great piece of application software is Apache. It is the most extensively used Web server program worldwide. Apache is the most popular Web server application for Unix-like operating systems, even though it can be used on almost all platforms, like Windows and Linux. The name of the Native American tribe known as the Apache, which was skilled in fighting and strategic thinking, served as the inspiration for the word “Apache”.

At certain times, you need to quickly deploy a web server. Implementing a proof-of-concept project, testing web apps, or simply becoming comfortable with web programming are all made simple with a web server. The below steps will show you how to deploy an Apache web server on your machine.

Install Apache in CentOS

Apache can be found in the default CentOS repositories. So, installing is easy when you use the yum package manager. You can do it as a user or a root user. Here, we will guide you on how to do it as a user other than root.

  • Run this command in your terminal to update the local Apache httpd package:
sudo yum update httpd
  • Install the httpd package and its dependencies:
sudo yum install httpd -y
  • Make sure your firewall is set up to accept queries on port 80. To achieve this, use the following command to turn on the http service in firewalld if you haven’t already:
sudo firewall-cmd --permanent --add-service=http
  • If you want Apache to provide HTTPS content, you must enable the https service and open port 443.
sudo firewall-cmd --permanent --add-service=https
  • Please reload the firewall so that the updated policies may take effect:
sudo firewall-cmd --reload
  • Once the CentOS installation is done, Apache does not start up by itself. You will have to manually start the Apache process:
sudo systemctl start httpd
  • Use the following command to check if the service is running:
sudo systemctl status httpd

Note: When the service is running, you will see that it is “active”. From the above output, it looks like the service started up fine. The best way to test this, though, is to ask Apache for a page. You can use your IP address to check that the software is running correctly by going to the default Apache landing page. You can get your server’s IP address in a few different ways from the command line if you don’t know it.

hostname -I
  • There are two options to check your apache server. Use the IP address from the output of the previous command and use curl or paste the IP address on the browser to load the Apache server. Using the curl we will get the following output:
curl 192.168.0.153

Note: In your case, the IP address 192.168.0.153 will be different. Use the one from the output of command “$ hostname -I “. Now, you can see the output of the HTML file of your Apache web page.

Copy and paste the IP address on your browser and hit enter.

If the default Apache web page loads successfully, then the server is functioning properly. Congratulations!

Feedback

Do you want to provide us with feedback? Provide us with feedback directly at info@elearnbee.com.

Share us:

AD BLOCK 1