首页 文章

为什么info.php只有放在/ var / www / html而不是/ var / www /?

提问于
浏览
0

我刚刚部署了LAMP以准备Elgg安装 . 在我部署了apache和php之后,我想通过创建info.php文件来测试我的进度 . 我将文件放在/ var / www /中,并尝试从浏览器访问它只是为了得到一个错误:

Not Found

The requested URL /info.php was not found on this server.

Apache/2.4.7 (Ubuntu) Server at 192.168.0.9 Port 80

当我在/ var / www / html中放置相同的文件时,它工作并显示Apache和php安装设置 . 任何人都可以向我解释为什么?用于教育目的 .

3 回答

  • 1

    Apache Webserver将显示放置到特定位置的文档 . 该位置的根称为文档根 .

    例如,如果DocumentRoot设置为 /var/www/html ,那么对 http://www.yoursite.com/folder1/yourpage.php 的请求将导致文件 /var/www/html/folder1/yourpage.php 被提供给请求客户端

    在ubuntu中,默认位置是 /var/www 用于服务器root,而在Centos上它是 /var/www/html

    此更改需要重新启动服务 .

    您可以从 /etc/httpd.conf 更改此位置,其中有一个关于文档根目录的部分 .

    但是你的发行版再次出现在u33ntu下面 /etc/apache2/http.conf

    基于Debian的系统

    ServerRoot              ::      /etc/apache2
    DocumentRoot            ::      /var/www
    Apache Config Files     ::      /etc/apache2/apache2.conf
                            ::      /etc/apache2/ports.conf
    Default VHost Config    ::      /etc/apache2/sites-available/default,/etc/apache2/sites-enabled/000-default
    Module Locations        ::      /etc/apache2/mods-available, /etc/apache2/mods-enabled
    ErrorLog                ::      /var/log/apache2/error.log
    AccessLog               ::      /var/log/apache2/access.log
    cgi-bin                 ::      /usr/lib/cgi-bin
    binaries (apachectl)    ::      /usr/sbin
    start/stop              ::      /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)
    
  • 0

    Apache的默认DocumentRoot是/ var / www / html . 编辑位于 /etc/apache2 目录中的httpd.conf配置文件,并将DocumentRoot更改为/ var / www

  • 1

    因为 /var/www/html 是apache的默认文档根路径 . 您可以在 /etc/apache2/sites-available/default.conf 中编辑路径 . 找到DocumentRoot为

    /var/www/html
    

    enter image description here

相关问题