MAMP htdocs phpinfo
我正在尝试获取一个简单的 phpinfo()
在本地服务器上打印(使用 MAMP)。我在 /Applications/MAMP/htdocs (php_sandbox)
中创建了一个新目录,并在其中放置了一个名为 my_phpinfo
的文件,其中仅包含 phpinfo()
它。如何在网络浏览器中查看该文件的内容?
如果我将 Apache 文档根目录设置在我的 home 目录/站点
中是否也可取?我将主要使用这个本地服务器来测试/托管一些小网站。
谢谢!
I am trying to get a simple phpinfo()
to print out on my local server (using MAMP). I made a new directory in /Applications/MAMP/htdocs (php_sandbox)
and put a file in there named my_phpinfo
with only phpinfo()
in it. How can I view the contents of this file in my web browser?
Is it also advisable if I set the Apache document root to be in my home directory/sites
? I will be mainly using this local server to test/host some small sites.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在浏览器中访问
localhost/my_phpinfo/index.php
假设您将该文件命名为<代码> 位于
index.php
中。另外,通过检查您的 mamp 首选项并查看 php MAMP 使用的版本,确保您在 MAMP 目录中编辑正确的 php.ini。visit in your browser
localhost/my_phpinfo/index.php
assuming you named the file with<? phpinfo();?>
is inindex.php
. Also, make sure you are editing the correct php.ini in your MAMP directory by checking your mamp prefs and seeing what version of php MAMP is using.根据我的记忆,默认情况下您位于正确的文件夹中。 MAMP 默认在端口 8888 上运行 apache。您应该能够访问 http://localhost:8888/ 您也可以通过控制面板访问此页面(应该有一个打开主页的按钮)。此页面还将显示您已将 MAMP 的 Apache 配置为在不同端口上运行。
无论您为文件命名什么;您需要为其指定 .php 扩展名,因此,如果您的文件名为
my_phpinfo
,请添加 .php,使其成为my_phpinfo.php
。确保您调用的函数包含在 php 标签中,如下所示如果此文件是 htdocs 文件夹中的目录,您应该能够转到 http://localhost:8888/my_phpinfo.php 并获取 PHP 信息页面。
目前正在移动目录。我通常这样做。尤其是 b/c,它使升级 MAMP 变得更容易(已经不必担心 MySQL)。您可能需要稍微调整文件权限以确保它正确运行。我相信你应该没问题,因为它是以你的用户身份运行的。
Your in the right folder by default from what I remember. MAMP runs apache on port 8888 by default. You should be able to go to http://localhost:8888/ You can also get to this page via the control panel (should have a button to open home page). This page will also show you've configured MAMP's Apache to run on a different port.
Whatever you name your file; you'll want to give it a .php extension, so if you file is named
my_phpinfo
, add a .php so it becomesmy_phpinfo.php
. Make sure you function called is wrapped in php tags like soIf this file is directory in the htdocs folder you should be able to go to http://localhost:8888/my_phpinfo.php and get the PHP Info page.
As far is moving the directory. I normally do. Especially b/c it makes upgrading MAMP a little easier (already have to worry about MySQL). You might have to tweak the file permissions just a bit to make sure it runs correctly. I believe though you should be okay since it is running as your User.