Apache - Apache2 Debian默认页面显示,而不是我的网站

6
我在Debian上安装了Apache 2,并且是一名初学者。 当我在网络浏览器中访问我的Web服务器时,我会看到Apache默认的欢迎页面(如下图所示):

enter image description here

相反,我想要显示我的真正网站(位于var/www/mywebsite.com/),而不是这个页面(位于var/www/html)。以下是我的服务器上的目录树:
---- etc
-------- apache2
------------ sites-enabled
---------------- mywebsite.com.vhost -> etc/apache2/sites-available/mywebsite.com.vhost
------------ sites-available
---------------- mywebsite.com.vhost

---- var
-------- www
------------ mywebsite.com
---------------- web
-------------------- css/
-------------------- js/
-------------------- img/
-------------------- error/
-------------------- index.html
-------------------- robots.txt

我的.vhost文件已经配置好了:
AllowOverride None
Require all denied

DocumentRoot /var/www/mywebsite.com

ServerName mywebsite.com
ServerAlias www.mywebsite.com
ServerAdmin webmaster@mywebsite.com

ErrorLog /var/log/ispconfig/httpd/mywebsite.com/error.log

Alias /error/ "/var/www/mywebsite.com/web/error/"
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html


<Directory /var/www/mywebsite.com/web>

    # Clear PHP settings of this website
    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler None
    </FilesMatch>
    Options +FollowSymLinks
    AllowOverride All
    Require all granted.

</Directory>

我尝试重新启动了Apache,但没有成功!Apache默认页面仍然存在。我错过了什么吗?

5个回答

1

删除 index.html

您的 index.html 位于 /var/www/html

  1. cd /var/www/html
  2. sudo chown -R whoami /var/www/html
  3. rm index.html
  4. ls

0
你的 index.html 文件位于 /var/www/mywebsite.com/web,我猜这是网站根目录?尝试使用以下配置:
DocumentRoot /var/www/mywebsite.com/web

你好Ben,同样的结果。我发现Apache加载的唯一*.conf文件是etc/apache2/sites-available/000-default.conf。 - Paolito75

0
我找到了解决方案。
Apache 只加载 etc/apache2/sites-available/000-default.conf 这个 *.conf 文件,所以我在这个文件上工作,解决了我的问题。
希望这能帮助未来的某个人!

0

只需从此路径 /var/www/html 中删除这两个文件 index.html 和 index.nginx-debian.html 即可......好的


0

你不需要删除任何东西。你只需用新的html/css/js内容更新index.html文件。请记住,更改只有在重新启动Debian后才会生效。虽然有一种立即查看更新的选项,但需要使用另一个命令。


你好,你能解释一下“即时更新”选项是什么吗? - pierpy
这是在安装apache2时添加的一个选项,可以使您对php、http、css等所做的更新立即生效,而无需重启机器。如果您感兴趣,我可以进一步了解。我在debian上看到了这个选项,其他Linux安装可能不一样。 https://www.cyberciti.biz/faq/apache-2-reload-httpd-config-file-unix-linux-command/ - project_2501

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接