macos XAMPP for Mac 看不到 PHP 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1326008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XAMPP for Mac cannot see PHP files
提问by Phill Pafford
I am unable to see php files after I downloaded XAMPP. I am trying to write a php file, so I download and started XAMPP, but I cannot see PHP files show up. When I open anything as simple as:
下载 XAMPP 后,我看不到 php 文件。我正在尝试编写一个 php 文件,所以我下载并启动了 XAMPP,但我看不到 PHP 文件显示出来。当我打开任何简单的东西时:
<?php
echo "Hello World";
?>
Just a blank Firefox window shows up. Can anyone please help?
只显示一个空白的 Firefox 窗口。有人可以帮忙吗?
回答by Phill Pafford
What directory are you using for your PHP files? This needs to be in the htdocs directory in the xampp directory. Check to see if xampp is running by typing http://localhostin your browser URL. If you see the xampp page come up then it's working fine and you need to check if your PHP files are in the correct location. If nothing shows up then it's xampp that's not working.
您为 PHP 文件使用的目录是什么?这需要在 xampp 目录中的 htdocs 目录中。通过在浏览器 URL 中键入http://localhost来检查 xampp 是否正在运行。如果您看到 xampp 页面出现,那么它工作正常,您需要检查您的 PHP 文件是否位于正确的位置。如果没有任何显示,则是 xampp 不起作用。
I just checked for the document root directory on the xampp website. It's /Applications/XAMPP/htdocs/ if you installed the xampp application in the applications directory.
我刚刚在 xampp 网站上检查了文档根目录。如果您在应用程序目录中安装了 xampp 应用程序,则它是 /Applications/XAMPP/htdocs/。
回答by Palantir
It's hard to guess without an error message. Try this: edit your php.ini (I don't know where this would be in XAMPP, but you should be able to find it) and look for this variable setting:
如果没有错误消息,很难猜测。试试这个:编辑你的 php.ini(我不知道它在 XAMPP 的什么位置,但你应该能够找到它)并寻找这个变量设置:
display_errors
if it is set to Off, turn it to On, then restart XAMPP. When you load the page, you should see some meaningful error message on the screen.
如果设置为关闭,将其打开,然后重新启动 XAMPP。当您加载页面时,您应该会在屏幕上看到一些有意义的错误消息。
回答by Hannah
put the folder or files in the (lowercase) xampp folder. Applications/XAMPP/htdocs/xampp then try the url: localhost/xampp/folder/file.php That should work.
将文件夹或文件放在(小写)xampp 文件夹中。Applications/XAMPP/htdocs/xampp 然后尝试 url: localhost/xampp/folder/file.php 这应该可以工作。
回答by Cyber
Check if the below is included in your httpd.conf
检查以下内容是否包含在您的 httpd.conf 中
Let Apache run phtml files
让Apache运行phtml文件
AddHandler application/x-httpd-php .php .php5 .php4 .php3 .html .htm .phtml
回答by pavium
Apache will need a bit of configuration in the httpd.conf file before it treats PHP files with the respect they deserve.
Apache 需要在 httpd.conf 文件中进行一些配置,然后才能以应有的尊重对待 PHP 文件。
(Only joking about the respect)
(只是开玩笑的尊重)
I'm using XAMPP for Windows, and I needed to add the following to the httpd.conf file:
我在 Windows 上使用 XAMPP,我需要将以下内容添加到 httpd.conf 文件中:
LoadModule php5_module "C:/Program Files/xampp/apache/bin/php5apache2.dll" AddType application/x-httpd-php-source .phps AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml
There may be some more details I've forgotten. It was a long time ago.
可能还有一些细节我忘记了。很久以前了。