AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1229521
Accepted
Praveen
Praveen
Asked: 2020-04-23 08:56:40 +0800 CST2020-04-23 08:56:40 +0800 CST 2020-04-23 08:56:40 +0800 CST

Apache 提供“It works”页面而不是网站的主页

  • 772

我的网站www.domainname.com加载 apache2 'It works' 页面,而不是预期的 moode 主页,该主页位于/var/www/html/moodle. 在moodle目录中有一个索引文件index.php,但默认不使用。如果我去www.domainname.com/moodle网站主页来。配置文件/etc/apache2/sites-available/domainname.conf已启用。如何解决这个问题?

<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.domainname.com
    ServerAlias domainname.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/moodle
    DirectoryIndex "index.php"
    # <Directory /var/www/html/>
    #       AllowOverride All
    # </Directory>  

    # 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
 RewriteEngine on
 RewriteCond %{SERVER_NAME} =www.domainname.com
 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
server apache2 webserver 18.04
  • 3 3 个回答
  • 7525 Views

3 个回答

  • Voted
  1. Newo
    2020-04-23T11:48:02+08:002020-04-23T11:48:02+08:00

    您必须禁用示例站点并启用您的moodle站点。您可以使用a2ensiteanda2dissite命令来执行此操作。要启用或禁用 Apache 托管的站点,您可以分别使用“a2ensite”和“a2dissite”命令。这两个命令使用基本相同的语法:

    a2ensite [site]
    a2dissite [site]

    您站点的虚拟主机配置文件的名称在哪里[site],位于 中/etc/apache2/sites-available/,减去“.conf”扩展名。例如,如果您的站点的虚拟主机配置文件被调用moodle.com.conf并且“It Works!” 配置文件被调用example.com.conf,那么命令将如下所示:

    a2ensite moodle.com
    a2dissite example.com

    之后,您可以通过键入重新启动 Apache sudo systemctl restart apache2,它现在应该可以工作了。

    (源自How do I enable/disable a website hosted with Apache? | Linode Questions)

    • 2
  2. Fractalyse
    2020-04-23T11:30:15+08:002020-04-23T11:30:15+08:00

    这是因为您使用的是默认html目录。

    移至/var/www/html/moodle_/var/www/

     mv var/www/html/moodle /var/www  
    

    更改DocumentRoot /var/www/html/moodle为DocumentRoot /var/www/moodle在您的domainname.conf

    用于a2ensite启用站点或创建符号链接以/etc/apache2/site-enabled/

    a2ensite domainname.conf
    

    只需使用重新加载 apache2systemctl reload apache2

    现在这应该可以按预期工作。

    • 0
  3. Best Answer
    Praveen
    2020-04-25T03:16:19+08:002020-04-25T03:16:19+08:00

    这可以通过更改行来解决

    DirectoryIndex index.php
    

    至

    DirectoryIndex index.php /moodle/index.php
    

    在文件中/etc/apache2/sites-available/site.conf。

    来源: https ://httpd.apache.org/docs/2.4/mod/mod_dir.html

    • 0

相关问题

  • 使用 dpkg 手动安装软件包是否会阻止未来的升级路径?

  • 如何从命令行刻录双层 dvd iso

  • 如果在服务器机器上运行 Ubuntu 桌面版,性能损失是多少?

  • 将桌面版剥离为服务器版的最简单方法是什么?

  • 如何与无头服务器进行图形交互?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve