首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如果直接浏览到IP,apache2上的默认VHOST无法工作

如果直接浏览到IP,apache2上的默认VHOST无法工作
EN

Server Fault用户
提问于 2019-11-24 15:54:30
回答 1查看 35关注 0票数 0

我在Ubuntu18.04上用Apache2拔头发。

我有几个指向Vhosts的域,它们似乎可以工作,但由于某些原因,直接浏览到IP时,如果只是转发到一个vhost,而不是/var/www/html目录的根目录。怎么一回事?这在Centos上有效,但在Ubuntu上不起作用。

代码语言:javascript
运行
复制
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html

            
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
            

            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined

            
                DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
            


    
        ServerAdmin webmaster@localhost
        ServerName domain.com
        ServerAlias domain.com
        DocumentRoot /var/www/html/domain.com/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
EN

回答 1

Server Fault用户

回答已采纳

发布于 2019-11-24 17:40:25

站点中是否启用了1000-default.conf?如果没有,可以创建它并将第一个虚拟移动到其中:

代码语言:javascript
运行
复制
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm

现在为您的其他虚拟化创建一个.conf,其中包含10-this-域和20-那个域之类的升序文件。

在apache2.conf中,您可能应该使用以下行

代码语言:javascript
运行
复制
IncludeOptional sites-enabled/*.conf

启用目录站点保存虚拟化的所有主机文件。

在Ubuntu上开箱即用,我只需将新主机放到启用了的站点中即可。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/993108

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档