Reputation: 992
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!
Upvotes: 2
Views: 7916
Reputation: 3601
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 becomes my_phpinfo.php
. Make sure you function called is wrapped in php tags like so
<?php phpinfo(); ?>
If 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.
Upvotes: 0
Reputation: 9491
visit in your browser localhost/my_phpinfo/index.php
assuming you named the file with
<? phpinfo();?>
is in index.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.
Upvotes: 3