duan97689 2016-01-15 01:54
浏览 186
已采纳

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

I have just deployed LAMP in preparation for Elgg installation. After I deployed apache and php I wanted to test my progress by creating info.php file. I placed the file in /var/www/ and tried to visit it from the browser only to get an error:

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

when I placed the same exact file in /var/www/html it worked and displayed the Apache and php installation settings. Can anyone please explain to me why? for educational purposes.

  • 写回答

3条回答 默认 最新

  • duangang4940 2016-01-15 02:02
    关注

    Apache webserver will show documents that are put to a specific location. Root of that location is referred as document root.

    For example, if DocumentRoot were set to /var/www/html then a request for http://www.yoursite.com/folder1/yourpage.php would result in the file /var/www/html/folder1/yourpage.php being served to the requesting client

    In ubuntu default location is /var/www for server root and on Centos its /var/www/html

    This change requires a service restart.

    you can change this from /etc/httpd.conf where there is a section about document root.

    But again on your distro which is ubuntu its under /etc/apache2/http.conf

    Debian based systems

    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)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢