【问题标题】:how to change the Default page localhost debian to run an application如何更改默认页面 localhost debian 以运行应用程序
【发布时间】:2025-12-26 22:25:10
【问题描述】:

在 debian 中,我安装了一个应用程序“maarchrm”。在指南安装结束时,要求将第 127.0.0.1 行添加到文件“etc/hosts”中。 在这个文件中,我们发现这些行:

127.0.0.1       localhost debian
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

所以当我添加该行时,它变成了这样:

127.0.0.1       maarchrm
127.0.0.1       localhost debian
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

当我想使用地址“http://maarchrm”运行此应用程序时,会出现问题。它带我到“apache2 debian 默认页面” 这是 000-default :

#<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    #ServerAdmin webmaster@localhost
    #DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    # LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    # Include conf-available/serve-cgi-bin.conf
#</VirtualHost>
 Include /var/www/laabs/data/maarchRM/conf/vhost.conf

我该如何解决这个问题并提前感谢

【问题讨论】:

  • 评论此行127.0.0.1 localhost debian并发布结果
  • 我试过了,但没有结果它仍然把我带到默认页面

标签: debian apache2 debian-jessie


【解决方案1】:

注释 000-default.conf &lt;virtualhost *:80&gt; 中的每一行。像这样。

#<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

#ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
# LogLevel info ssl:warn

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

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
# Include conf-available/serve-cgi-bin.conf
# Application Maarch RM 
#</VirtualHost>
Include /var/www/laabs/data/maarchRM/conf/vhost.conf

然后重启apache。这应该可以解决它


编辑

删除 /var/www/html/ 中的 index.html 并以 root 身份运行以下命令:

find /var/www/laabs/web/ -type f -print0 | sudo xargs -0 chmod 644
find /var/www/laabs/web/ -type d -print0 | sudo xargs -0 chmod 755

【讨论】:

  • 我试过了,但不幸的是它没有用。也许还有另一个技巧。
  • 编辑您的问题并发布实际的 000-default.conf 文件,每行都带有 #。问题是 DocumentRoot /var/www/html 在配置中的某处被调用,这就是您看到 apache 默认页面的原因。
  • 刚刚编辑了我的问题,请尝试并报告输出
  • 抱歉没有回复,我刚刚重新安装了应用程序,它就像魔术一样工作。无论如何感谢您的回答:)
最近更新 更多