Updated on 2025-07-29 GMT+08:00

Installing Apache

Introduction

Apache HTTP Server (Apache for short) is free open-source cross-platform web server software developed by the Apache Software Foundation. It can run in most operating systems and is widely used because of its high security. As one of the most popular web servers, Apache supports FastCGI and SSL and can integrate with Perl. This section describes how to deploy Apache in HCE 2.0.

Preparations

  • Prepare an ECS and assign a public IP address or EIP to the ECS.
  • Ensure that inbound security group rules allow traffic to flow to the ECS over port 80.

Prerequisites

A yum repository has been configured. For details about how to configure a yum repository accessed over the Internet, see Configuring Repositories and Installing Software for HCE.

Procedure

  1. Install Apache.

    1. Run the following command to install Apache:
      dnf install httpd httpd-devel

      After the installation is complete, the Apache configuration file is /etc/httpd/conf/httpd.conf.

    2. Run the following command to check the Apache version:
      httpd -v

      Information similar to the following is displayed:

      [root@localhost system]# httpd -v
      Server version: Apache/2.4.51 (Unix)
      Server built:   Feb  9 2022 09:00:41
    3. Run the following command to start Apache:
      systemctl start httpd

      If active (running) is displayed, Apache is started.

      To enable Apache to automatically start upon system boot, run the following commands in sequence:

      systemctl enable httpd
      systemctl daemon-reload

  2. Verify Apache.

    1. Run the following command to create a test page:
      echo test > /var/www/html/index.html
    2. Enter http://<Public IP address> in the address box of the browser. If the following information is displayed, the deployment is successful.
      Figure 1 Successful deployment