# Apache安装
#### 简介
Apache HTTP Server（简称Apache）是Apache软件基金会的一个开源网页服务器，可以在大多数操作系统中运行，由于其能跨平台、安全性高而被广泛使用，是最流行的Web服务器软件之一，其拥有的特性包括支持FastCGI、支持SSL、集成Perl处理模块等。本教程介绍如何在HCE中部署Apache。
#### 准备工作
- 准备一台ECS，并分配公网IP或者弹性公网IP（EIP）。
 
- 安全组入方向已放通80端口。
#### 前置条件
已完成本机yum源的配置，可参考[HCE的REPO源配置](https://support.huaweicloud.com/usermanual-hce/hce_repo.html)进行yum源的配置。
#### 操作步骤
1. 安装Apache软件。 
   1. 执行如下命令安装Apache服务：
      ```
      dnf install httpd httpd-devel
      ```
      执行完后，Apache服务配置文件路径为：*/etc/httpd/conf/httpd.conf*。
      
   
   2. 执行以下命令查看Apache版本号：
      ```
      httpd -v
      ```
      输出内容示例如下：
      ```
      [root@localhost system]# httpd -v
      Server version: Apache/2.4.51 (Unix)
      Server built:   Feb  9 2022 09:00:41
      ```
      
   
   3. 执行如下命令启动Apache服务：
      ```
      systemctl start httpd
      systemctl status httpd
      ```
      如果输出显示**a** **ctive (running)**，则表示启动成功。
      ![](https://support.huaweicloud.com/bestpractice-hce/public_sys-resources/note_3.0-zh-cn.png)
      如果要将Apache服务设置为开机自启动，则需要依次执行以下命令：
      ```
      systemctl enable httpd
      systemctl daemon-reload
      ```
      
   
   
   
   
2. 验证。 
   1. 执行以下命令创建测试页面：
      ```
      echo test > /var/www/html/index.html
      ```
      
   
   2. 在浏览器中输入http:*//\<公网IP\>* ，如果显示如[图1]，则表示部署成功：
      图1部署成功   
      ![](https://support.huaweicloud.com/bestpractice-hce/zh-cn_image_0000002479928558.png "点击放大") 
   
   
   
   
 
