You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AWS EB CLI创建/部署时如何选择Apache作为代理服务器?

在AWS Elastic Beanstalk中指定Apache作为代理服务器

1. 创建新环境时直接指定Apache平台

先通过EB CLI查看可用的支持Apache的平台版本:

eb platform list

在输出列表中找到带有Apache标识的平台(例如PHP 8.2 running on 64bit Amazon Linux 2023 with Apache、Python 3.11 running on 64bit Amazon Linux 2023 with Apache等),创建环境时指定该平台即可:

eb create 你的环境名称 --platform "选中的Apache平台名称"

2. 为现有环境切换到Apache

如果已经创建了默认用Nginx的环境,可通过添加配置文件强制切换:

  • 在项目根目录创建.ebextensions文件夹
  • 在该文件夹内新建01-apache-proxy.config文件,内容如下(注意替换应用实际监听端口):
packages:
  yum:
    httpd: []

services:
  sysvinit:
    nginx:
      enabled: false
      ensureRunning: false
    httpd:
      enabled: true
      ensureRunning: true

files:
  "/etc/httpd/conf.d/elasticbeanstalk.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      <VirtualHost *:80>
        ProxyPass / http://localhost:8000/
        ProxyPassReverse / http://localhost:8000/
        ProxyPreserveHost On
        ErrorLog /var/log/httpd/elasticbeanstalk-error.log
      </VirtualHost>
  • 部署更新后的配置到环境:
eb deploy

3. 验证切换结果

部署完成后,登录EC2实例执行以下命令确认状态:

sudo systemctl status httpd
sudo systemctl status nginx

若httpd处于active (running)状态、nginx处于inactive (dead)状态,说明切换成功。

内容的提问来源于stack exchange,提问作者schierkolk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 03:12:18