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条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器