gpt4 book ai didi

apache - ubuntu 13.10 和 apache 2.4.6 上的虚拟主机

转载 作者:行者123 更新时间:2023-12-01 17:53:33 25 4
gpt4 key购买 nike

我遇到以下问题
我的hosts文件如下:

127.0.0.1       localhost
127.0.1.1 barbala4o-HP-ProBook-4530s
127.0.1.1 mysite.localhost

我的文件在 /etc/apache2/sites-available/mysite.localhost.conf如下:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mysite.localhost

DocumentRoot /var/www/mysite

<Directory /var/www/mysite/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/mysite-error.log
CustomLog /var/log/apache2/mysite-access.log common
</VirtualHost>

之后sudo a2ensite mysite.localhost.conf并在 mysite.localhost/上重新启动 apache,并且仅在 localhost 上我得到以下内容(例如列出其中没有索引文件的目录):

Index of /

[ICO] Name Last modified Size Description
[DIR] apache_logs/ 2013-09-24 10:15 -
[DIR] mysql/ 2013-10-22 10:05 -
[DIR] tools/ 2013-10-22 10:05

以及 /var/www/ 中的任何其他文件夹当我输入 localhost/test 时,像 test 这样的目录而不是加载 index.php它显示的文件:

Not Found

The requested URL /adlantic was not found on this server.

Apache/2.4.6 (Ubuntu) Server at localhost Port 80

如果我这样做sudo a2dissite mysite.conf并重新启动 apache 一切加载正常。我猜问题出在mysite.localhost.conf中的某个地方但我找不到在哪里。有任何想法吗? 10倍

最佳答案

Ubuntu 13.10 及其变体已迁移至 Apache 2.4。 Apache 2.4 希望启用的虚拟主机配置文件默认以 .conf 结尾。

解决方案

现在要解决此问题,您可以使用两种方法来获得相同的结果。

  1. 第一个解决方案也是简单的解决方案,是向所有虚拟主机添加 .conf 扩展名。新的 Apache 2.4 读取 site-available 目录中的每个虚拟主机,其扩展名在新的 Apache 2.4 配置文件中概述。

  2. 第二种解决方案是删除位于/etc/apache2/apache2.conf 的 Apache 2.4 配置文件中的 .conf 扩展名

在旧的 Apache 2.2 文件中,.conf 文件有一个包含站点启用/,而新的 .conf 文件有

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

将该行更改为:

# Include the virtual host configurations:
IncludeOptional sites-enabled/

结果:命令 a2ensite yourdomain 现在按预期运行。如果您使用的是第二种方法;您的虚拟主机文件不需要具有 .conf 扩展名。

Note: Configuration file is "/etc/apache2/apache2.conf" in new Apache, so please copy document root path and other configurations from "/etc/apache2/sites-available/000-default.conf" to  "/etc/apache2/apache2.conf"

关于apache - ubuntu 13.10 和 apache 2.4.6 上的虚拟主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19518907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com