Ubuntu PHP5安装找不到URL的问题

错误404,具体内容:

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


按照网上的教程安装完apache

sudo apt-get install apache2

然后安装PHP5

sudo apt-get install php5 libapache2-mod-php5 php5-mysql

创建测试脚本

 sudo gedit /var/www/testphp.php

内容为:

浏览器中输入

127.0.0.1/testphp.php

会显示错误

因为 /etc/apache2/sites-availables/000-defaulr.conf 文件才是真正的根目录的一个配置,和centos不太一样的

里面的内容如下


    # 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.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www

    # 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


显然根目录是www/html即你的文件需要在www/html文件夹下面,网上的命令你创建的testphp.php实际上位于www目录下面

可以cp指令把文件拷贝到www的子目录html下面就可以正常的显示了

也可以把这个地方的html去掉



你可能感兴趣的:(WEB,PHP5,Ubuntu)