如何在亚马逊的单个实例中部署两个 PHP 应用程序

How to deploy two PHP applications in a single instance in amazon

我最近开始使用 AWS 服务。

我在 EBS 上有一个 symfony 3 应用程序 运行ning - 使用单个 EC2 实例(带有 Linux AMI)配置了 EIP 并且 public 客户端可以访问。我已经通过使用 Github 创建管道并通过 Travis-CI 推送代码将其部署到 EBS。

我想 运行 另一个 PHP 应用程序 - OSTicket(而不是托管)在同一个实例中,以便 EBS 可以访问它 public URL 作为子域。 我怎样才能在保持持续集成的同时实现这一目标?

您可以在 /var/www/html 文件夹中创建 2 个目录,分别命名为 site1 和 site2。 导航到文件夹 /etc/apache2/sites-available.

中的 000-default.conf 文件

添加具有不同端口号的虚拟主机值的第二个网站的目录。

然后转到 apache2 目录中的 ports.conf 文件并添加 Listen

这将帮助您在同一 EC2 实例上 运行 2 个不同的 PHP 应用程序。

如果您使用的是 Apache,则需要设置基于名称的虚拟主机条目。 (nginx 有类似的东西)

然后你可以有两个不同的配置,指向不同的文档根,像这样:

<VirtualHost *:80>
  ServerName site1.example.com

  DocumentRoot /var/www/html/site1
  DirectoryIndex index.php

  ErrorLog logs/site1_error.log
  CustomLog logs/site1_access.log
  <Directory "/var/www/html/site1">
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName site2.example.com

  DocumentRoot /var/www/html/site2
  DirectoryIndex index.php

  ErrorLog logs/site2_error.log
  CustomLog logs/site2_access.log
  <Directory "/var/www/html/site2">
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>