【问题标题】:PHP xampp downloading my index.php instead of loading the pagePHP xampp 下载我的 index.php 而不是加载页面
【发布时间】:2013-07-11 23:07:13
【问题描述】:

所以我的 PHP 项目导致 localhost 以及 localhost/project/ 正在为项目下载 index.php 而不是加载它,它将它下载为 download...这里是 download 文件:

<?php   
/*
* Index.php - Define the directories
*
*
* DS, DIRECTORY_SEPARATOR = /
* ROOT, dirname = string containing the path of a file or directory
* __FILE__ = The full path and filename of the file. If used inside an include, the name of the included file is returned
*
* In this file we load the apporpriate files that our website wants to load and render the
* template with informatio from the database. We load the bootstrap.php from the library folder.
*
* We are not including the ?\>  to avoid injection of any extra whitespaces in our output.
*
*
*/


define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(dirname(__FILE__)));

$url = $_GET['url'];

require_once (ROOT . DS . 'library' . DS . 'bootstrap.php');

加载localhost 会下载这个:

<?php
    if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
        $uri = 'https://';
    } else {
        $uri = 'http://';
    }
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri.'/xampp/');
    exit;
?>
Something is wrong with the XAMPP installation :-(

【问题讨论】:

  • 您可能没有为 apache 加载 PHP 模块?
  • 你知道如何在 ubuntu 上手动加载这个吗?我会搜索尝试一下
  • 你真的在 Ubuntu 上使用 XAMPP 吗?我的意思是,来自 apachefriends 的东西? - 他们甚至无法让自己的网站正确(或者#META TITLE# 应该是实际的页面标题?)。只需“sudo apt-get install apache2 php5 libapache2-mod-php5 mysql”就可以了……
  • 嘿@germainelol,你真的找到解决方案了吗?我想我遇到了完全相同的问题....
  • 我不认为这是 php 处理程序的问题。检查您的 index.php 文件是否具有执行权限。尝试“chmod 644 index.php”。为 index.php 授予 644 权限。它会解决:)

标签: php xampp


【解决方案1】:

除了更新 php.ini 文件并设置 enable_post_data_reading=On 之外,请确保启动 XAMPP(转到安装位置并双击 xampp_start)

【讨论】:

    【解决方案2】:

    这适用于 MAC 版本 10.15.4。

    如果您安装了 XAMPP,您可以尝试在位于 /Applications/XAMPP/xamppfiles/apache2/conf 的 httpd.conf 中添加以下行。

    AddType application/x-httpd-php .htm .html

    如果我不起作用,请尝试删除浏览器的缓存或重新启动计算机。

    注意:如果你在同一个根目录下有.htaccess文件,你应该删除它以防止浏览器下载你的php或html文件。

    【讨论】:

      【解决方案3】:

      我在我的 Ubuntu 台式计算机上遇到了同样的问题。使用 filezilla(或任何其他文件资源管理器)我从父目录中删除了一个隐藏的 htaccess 文件。

      然后解决了。恢复正常网页显示。

      (我不确定那个 htaccess 文件对台式计算机是否重要,但我确定我没有在我的实时服务器上添加它。因此我删除了它。如果我错了,请告诉我)

      【讨论】:

        【解决方案4】:

        我有同样的问题(使用 Ubuntu 12.04)并且在 .htaccess 中也有一行,例如 pi4r0n,例如,

        AddHandler application/x-httpd-php54s .php
        

        XAMPP 的 PHP 版本与 AddHandlercommand 调用的 PHP 版本不同(我的是 v5.3.8)。我发现像 pi4r0n 那样将其注释掉,即,

        # AddHandler application/x-httpd-php54s .php
        

        将允许它在本地服务器上工作。您只需要记住在上传之前更改它。

        【讨论】:

        • 感谢它在我的 mac 中工作。我努力寻找使它起作用的原因并遵循所有可用的答案。最后只是在 .htaccess 文件中评论上面提到的内容。
        【解决方案5】:

        伙计们,我也遇到了完全相同的问题,在我的情况下是 htaccess 文件。我错误地从我的服务器(cPanel 服务器)下载了它,htaccess 看起来像这样

        # 默认使用 PHP5.4 AddHandler application/x-httpd-php54 .php

        但是因为我没有在XAMPP本地安装PHP5.4,所以不知道怎么处理这个文件。

        所以我的建议是确保您的 htaccess 文件(如果您有任何文件被删除或正确);)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-03-08
          • 2016-04-13
          • 2013-10-21
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多