在Ubuntu 13.10和Apache 2.4.6虚拟主机 [英] Virtual host on ubuntu 13.10 and apache 2.4.6

查看:353
本文介绍了在Ubuntu 13.10和Apache 2.4.6虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题

 我的hosts文件如下:

I have the following problem
My hosts file is as follows:

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>

在DO 须藤a2ensite mysite.localhost.conf 并重新启动mysite.localhost阿帕奇/只有在localhost我碰到下面的(如在列出一个目录没有索引文件它):

After do sudo a2ensite mysite.localhost.conf and restart apache on mysite.localhost/ and only on localhost i get the following (like listing a directory without index file in it):

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

和在类似试验中 /无功/网络/ 目录当我输入任何其他文件夹本地主机/测试而不是加载的的index.php 文件,它表明:

And on any other folder in the /var/www/ directory like test when i enter localhost/test instead of loading the index.php file it shows:

Not Found

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

Apache/2.4.6 (Ubuntu) Server at localhost Port 80   

如果我须藤a2dissite mysite.conf 键,重启apache一切都加载ok了。我想这个问题是某处 mysite.localhost.conf ,但我找不到在哪里。有任何想法吗? 10X

If I do sudo a2dissite mysite.conf and restart apache everything is loading ok. I guess the problem is somewhere in the mysite.localhost.conf but I can't find where. Any ideas? 10x

推荐答案

的Ubuntu 13.10和变种已经转移到Apache 2.4。阿帕奇2.4都想启用虚拟主机配置文件默认情况下的.conf结束。

Ubuntu 13.10 and variants have moved to Apache 2.4. Apache 2.4 wants enabled virtual host config files to end in .conf by default.

解决方案

我们有你可以用它来达到同样的效果两种方法解决此问题。

Now to correct this problem there are two methods you can use to achieve the same result.


  1. 第一个解决方案和简单的解决方案,是一个扩展的.conf添加到您所有的虚拟主机。新的Apache 2.4读取与新的Apache 2.4配置文件中列出的.conf扩展站点可用目录中的每个虚拟主机。

  1. The first solution and simple solution, is to add a .conf extension to all your virtual host. The new Apache 2.4 reads each virtual host in the sites-available directory with .conf extension outlined in the new Apache 2.4 configuration file.

第二个解决方法是删除了Apache 2.4配置文件中的.conf扩展位于/etc/apache2/apache2.conf

The second solution is to remove the .conf extension in Apache 2.4 configuration file located in /etc/apache2/apache2.conf

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

In the old Apache 2.2 file the .conf file had a Include sites-enabled/ whereas the new .conf file has

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

把上面一行写着:

Change that line to read:

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

结果:YOURDOMAIN现在运行正常命令a2ensite。如果您使用的是第二个方法;您的虚拟主机文件不需要有扩展的.conf

The results: the command a2ensite yourdomain now runs as expected. If you are using the 2nd method; your virtual host files do not need to have the .conf extension.

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"


  • 更多信息请访问:<一个href=\"http://lyemium.com/content/virtual-host-issues-when-upgrading-apache-22-24#sthash.VVRCvEwS.dpuf\">http://lyemium.com/content/virtual-host-issues-when-upgrading-apache-22-24#sthash.VVRCvEwS.dpuf

  • 这篇关于在Ubuntu 13.10和Apache 2.4.6虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆