Install Apache on CentOS 7: Complete Setup Guide

Install the Apache server:

  1. Open the terminal and use the following command to install the Apache server:
sudo yum install httpd
  1. After installation is complete, start the Apache server and set it to start automatically on boot.
sudo systemctl start httpd
sudo systemctl enable httpd

Set up an Apache server.

  1. The configuration file for the Apache web server.
sudo vi /etc/httpd/conf/httpd.conf
  1. You can configure some basic settings of the Apache server in the httpd.conf file, such as port number and virtual hosts. Modify the configuration file as needed.
  2. Once you have saved and exited the httpd.conf file, reload the Apache server configuration.
sudo systemctl reload httpd
  1. Configure the website’s root directory:

By default, the website root directory for an Apache server is /var/www/html/, where website files can be placed. If you want to change the website root directory, you can modify the DocumentRoot option in the httpd.conf file.

  1. Set up firewall:

If the firewall is enabled on the system, it is necessary to configure the firewall to allow HTTP traffic access. Use the following command to enable the HTTP service:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
  1. Test the Apache server.

Open a browser and type http://localhost or the server IP address in the address bar. If you can see the default Apache page, it means that the Apache server has been installed and configured successfully.

bannerAds