【问题标题】:How to add Virtual host on ec2 wiith Apache 2.4.18?如何使用 Apache 2.4.18 在 ec2 上添加虚拟主机?
【发布时间】:2016-10-29 02:50:32
【问题描述】:

我正在尝试将域指向 EC2 实例的特定文档根目录。 我已经设置了 Route 53,并将 DNS 设置为域。现在域点很好。 我还添加了主机到服务器的主机文件。 现在我想将以下代码添加到/etc/httpd/conf/httpd.conf。 我曾经对 Apache 2.2 做同样的事情。

NameVirtualHost *:80
<VirtualHost *:80>
        DocumentRoot /var/www/html/xyz
        ServerName xyz.com
</VirtualHost>

但是当我打开etc/httpd/conf/httpd.conf 时,文件似乎太小了虽然我已将相同的内容添加到etc/httpd/conf/httpd.conf 并且相同并使用service httpd restart 重新启动Apache。

谁能建议我如何添加它?

【问题讨论】:

    标签: apache amazon-web-services amazon-ec2 virtualhost


    【解决方案1】:

    我在add following code to /etc/httpd/conf/httpd.conf的底部添加了以下代码

    <VirtualHost *:80> ServerName xyz.com RewriteEngine On #RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] DocumentRoot /var/www/html/xyz <Directory /var/www/html/xyz> DirectoryIndex index.php AllowOverride All </Directory> </VirtualHost> 保存文件并重新启动 Apache,因为它会在您使用 service httpd restart 重新启动服务器后生效。

    【讨论】:

      猜你喜欢
      • 2012-07-08
      • 1970-01-01
      • 2020-09-28
      • 2017-02-27
      • 2013-04-04
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 2019-12-27
      相关资源
      最近更新 更多