linux - AWS EC2 上的 Apache VirtualHosts 不工作

标签 linux apache amazon-ec2

我正在尝试在我的 AWS EC2 Linux 服务器上设置虚拟主机。但是,它会继续将请求定向到默认页面。

我已经安装了 apache,当我在 /var/www/html/ 中创建索引文件时,它会按预期显示。

但是,当我添加一个 *.conf 虚拟主机时,它只会恢复默认页面。

我已经创建了我的 /etc/httpd/conf.d/{myvhost.conf} 文件:

<VirtualHost *:80>
    DocumentRoot "/home/username/www/public"
    ServerName ec2-13-55-0-7.ap-southeast-2.compute.amazonaws.com

</VirtualHost>

文档根目录已在/home/username/www/public 创建,我添加了自定义 index.html 文件,perms 设置为 755。

IncludeOptional conf.d/*.conf/etc/httpd/conf/httpd.conf

中取消注释

重启apache。

但是显示的是默认页面,而不是我的/home/username/www/public
为什么?

最佳答案

首先,如果你添加一些 Directory directives 就好了到您的根文件夹:

<Directory "/home/username/www/public/">
  allow from all
  Options +Indexes
</Directory>

或者(source):

<LocationMatch "^/+$">
    Options Indexes
</LocationMatch>

其次,你可以debug what Apache understand of the configuration :

# Check for syntax error
apachectl -t
# List VirtualHost
apachectl -S

# both checks:
apachectl -t -D DUMP_VHOSTS

当然,检查log files .

关于linux - AWS EC2 上的 Apache VirtualHosts 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41906041/

相关文章:

php - 如何让 Slim Framework 工作而不必在 URL 中放入/index.php?

opengl - 使用 CentOS 在 AWS GPU 实例上运行 OpenGL

sql-server - SQL Server JDBC 连接重置错误 : Only on Amazon EC2

c++ - 如何找到G++优化C++代码的错误?

c - Linux 源代码 - 任务交换开/关 CPU 以运行队列的位置

angularjs - 如何托管 Angularjs 应用程序或 M.E.A.N. Apache 或 NodeJS 服务器上的客户端应用程序?

linux - AWS EC2 错误 : -bash: cannot create temp file for here-document: No space left on device

python skimage.measure.label 在linux环境下导致segment fault

linux - 如何在 Expect 脚本中返回生成的进程退出代码?

linux - 需要帮助在 CentOS 5.5 上设置 Apache,得到 403