微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ubuntu 13.10和apache 2.4.6上的虚拟主机

我有以下问题
我的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并重新启动apache在mysite.localhost /和只有在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 /测试,而不是加载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的某个地方,但我找不到在哪里。有任何想法吗? 10x

Ubuntu 13.10和其他版本已移至Apache 2.4。认情况下,Apache 2.4希望启用虚拟主机配置文件以.conf结尾。

现在纠正这个问题有两种方法可以用来实现相同的结果。

>第一个解决方案和简单的解决方案,是将.conf扩展名添加到所有虚拟主机。新的Apache 2.4使用新的Apache 2.4配置文件中概述的.conf扩展读取sites-available目录中的每个虚拟主机。
>第二个解决方案是删除位于/etc/apache2/apache2.conf中的Apache 2.4配置文件中的.conf扩展

在旧的Apache 2.2文件中.conf文件具有Include sites-enabled /而新的.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"

>查看更多:http://lyemium.com/content/virtual-host-issues-when-upgrading-apache-22-24#sthash.VVRCvEwS.dpuf

原文地址:https://www.jb51.cc/ubuntu/351318.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐