Installation guides

Installing Apache on RHEL

Step-by-Step Guide

  1. Update the Package Index
    Open a terminal and update the package index to ensure you have the latest information about available packages:
   sudo yum update -y
  1. Install Apache
    Install Apache using the yum package manager:
   sudo yum install httpd -y
  1. Start and Enable Apache
    Start the Apache service:
   sudo systemctl start httpd

Enable Apache to start on boot:

   sudo systemctl enable httpd
  1. Adjust the Firewall
    Ensure that your firewall allows HTTP and HTTPS traffic. You can check the current firewall status and add the necessary rules:
   sudo firewall-cmd --permanent --add-service=http
   sudo firewall-cmd --permanent --add-service=https
   sudo firewall-cmd --reload
  1. Verify Apache Installation
    After the installation is complete, Apache should start automatically. You can verify this by checking the service status:
   sudo systemctl status httpd

If Apache is running, you should see an active (running) status.

  1. Test Apache
    Open your web browser and visit your server’s IP address (http://your_server_ip/). You should see the Apache Test Page, indicating that the web server is running correctly.
  2. Configure Apache (Optional)
    The main configuration file for Apache is located at /etc/httpd/conf/httpd.conf. You can edit this file to customize your Apache configuration:
   sudo nano /etc/httpd/conf/httpd.conf

After making changes, restart Apache to apply them:

   sudo systemctl restart httpd
  1. Enable/Disable Modules
    Apache uses modules to extend its functionality. You can enable or disable modules by editing the configuration files in the /etc/httpd/conf.modules.d/ directory. After enabling or disabling modules, reload Apache to apply changes:
   sudo systemctl reload httpd
  1. Set Up Virtual Hosts (Optional)
    Virtual hosts allow you to run multiple websites on a single server. To set up a virtual host, create a new configuration file in the /etc/httpd/conf.d/ directory:
   sudo nano /etc/httpd/conf.d/your_domain.conf

Add the following basic configuration to the file:

   <VirtualHost *:80>
       ServerAdmin webmaster@your_domain
       ServerName your_domain
       ServerAlias www.your_domain
       DocumentRoot /var/www/your_domain
       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
   </VirtualHost>

Save and close the file, then restart Apache to apply the changes:

   sudo systemctl restart httpd
Other Recent Posts