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 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作