Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache2 Ubuntu 12.10虚拟主机冲突_Apache2_Virtualhost_Ubuntu 12.10 - Fatal编程技术网

Apache2 Ubuntu 12.10虚拟主机冲突

Apache2 Ubuntu 12.10虚拟主机冲突,apache2,virtualhost,ubuntu-12.10,Apache2,Virtualhost,Ubuntu 12.10,我的服务器上有两个站点。我通过IP访问的一个,x.x.x.x/site1。另一个是注册域名www.mysite.com 最初,我只有/etc/apache/sites/default文件可用,但当我尝试加载上面的任何一个站点时,我只得到了/var/www/index.html输出 我为mysite.com添加了一个新的virtualhost,代码如下: <VirtualHost *:80> ServerAdmin webmaster@localhost Docume

我的服务器上有两个站点。我通过IP访问的一个,x.x.x.x/site1。另一个是注册域名www.mysite.com

最初,我只有
/etc/apache/sites/default
文件可用,但当我尝试加载上面的任何一个站点时,我只得到了
/var/www/index.html
输出

我为mysite.com添加了一个新的virtualhost,代码如下:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/mysite
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/mysite>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

服务器管理员webmaster@localhost
DocumentRoot/var/www/mysite
选项如下符号链接
允许超越所有
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
Mysite.com仅在禁用默认设置时加载,但是,x.x.x.x/site1不加载

因此,我启用默认的virtualhost,它具有以下代码:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/mysite
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/mysite>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

服务器管理员webmaster@localhost
DocumentRoot/var/www
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
现在,x.x.x.x/site1起作用,但mysite.com不起作用,而是加载/var/www/index.html页面


我对问题所在感到困惑。

在mysite.com的vhost配置中,您需要添加ServerName指令:

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

    DocumentRoot /var/www/mysite

    […]

服务器管理员webmaster@localhost
服务器名mysite.com
DocumentRoot/var/www/mysite
[…]

网站是基于哪种语言建立的。。这有助于给出明确的答案当你在文档根目录下加载主网站时,它下面的任何url都将在第一个应用程序中搜索。你可以将xx.xx/app1和xx.xx/app2或mysite.com连接到主网站,将site1.mysite.com连接到其他网站。这里的一些评论说,在ubuntu 12.10中,你必须将default更改为default.conf才能让你的mysite.com工作。就这么简单。非常感谢。