[英]PHP xampp downloading my index.php instead of loading the page
所以我的 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 :-(
我有同样的问题(使用 Ubuntu 12.04)并且在 .htaccess 中也有一行像 pi4r0n,例如,
AddHandler application/x-httpd-php54s .php
XAMPP 与AddHandler
命令调用的 PHP 版本不同(我的版本为 v5.3.8)。 我发现注释掉它,就像 pi4r0n 所做的那样,即,
# AddHandler application/x-httpd-php54s .php
将允许它在本地服务器上工作。 您只需要记住在上传之前对其进行更改。
伙计们,我也遇到了完全相同的问题,在我的情况下是 htaccess 文件。 我错误地从我的服务器(cPanel 服务器)下载了它,htaccess 看起来像这样
# 使用 PHP5.4 作为默认 AddHandler application/x-httpd-php54 .php
但是因为我没有在 XAMPP 上本地安装 PHP5.4,所以它不知道如何处理该文件。
因此,我的建议是确保您的htaccess文件是否已删除或正确;)
我在我的 Ubuntu 台式计算机上遇到了同样的问题。 使用 filezilla(或任何其他文件资源管理器)我从父目录中删除了一个隐藏的 htaccess 文件。
它被解决了。 恢复正常的网页显示。
(我不确定该 htaccess 文件对台式计算机是否重要,但我确定我没有在我的实时服务器上添加它。因此我删除了它。如果我错了,请告诉我)
这适用于 MAC 版本 10.15.4。
如果您安装了 XAMPP,您可以尝试在位于 /Applications/XAMPP/xamppfiles/apache2/conf 的 httpd.conf 中添加以下行。
AddType application/x-httpd-php .htm .html
如果我不起作用,请尝试删除浏览器的缓存或重新启动计算机。
注意:如果你在同一个根目录下有 .htaccess 文件,你应该删除它以防止浏览器下载你的 php 或 html 文件。
除了更新 php.ini 文件并设置 enable_post_data_reading=On 之外,请确保启动 XAMPP(转到安装位置并双击 xampp_start)
就我而言,问题是我在 cPanel 中有项目,如果尝试在我的本地执行项目,Xampp 上传文件而不是打开 localhost。
在 cPanel 中我有 7.2 版的 php,而在我的本地我有 7.4 版。
在我的情况下,这种使用的原因是 cPanel 在 .htaccess 文件中生成一个处理程序:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
所以为了能够在本地执行项目,我们需要注释这一行,如下所示:
#AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
**
php -- BEGIN cPanel 生成的处理程序,不要编辑设置“ea-php74”
包作为默认的“PHP”编程语言。
AddHandler 应用程序/x-httpd-ea-php74___lsphp .php .php7 .phtml
php -- 结束 cPanel 生成的处理程序,不要编辑
https://mega.nz/file/PU803bDA#evpjZZ0Yz6KQYw8xWVvIz_RNqV4xeyHq5RhDEtcNUYI
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.