Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just installed MAMP 2.1.1 on OS X 10.7.4. The MAMP Start page says everything is running.

MySQL is running, I can issue command line commands in Terminal. I tested PHP by typing:

php -f testphp.php

where testphp.php contained one line of code:

<?php echo phpinfo(); ?>

In the terminal window, this returned the expected - an extensive listing of PHP config info. All appears to be well, but if I direct Safari to a simple PHP page, instead of seeing the page run, I get a listing of its source code!

I built a page whose body is:

<body>
Testing PHP:
<?php echo phpinfo(); ?>
</body>

I called it testphp.php. If I go to :

localhost/testphp.php

I see the source code listing! If I rename the file to testphp.html, I see:

Testing PHP:

but that's all - the line of PHP code produces nothing.

Can anyone explain why my localhost server won't talk PHP?

share|improve this question
add comment

1 Answer 1

First:
Are you really going through the server?
Try

`http://localhost/testphp.php`

Second:
Is the server set up for php? Is the server set up to read from wherever you have your source file?

share|improve this answer
    
I found most of the answer at apple.stackexchange.com/questions/23751/… Note that the virtual host configuration didn't seem to be necessary. –  Marc in Felton Aug 8 '12 at 9:53
    
After following the info at apple.stackexchange.com/questions/23751/… –  Marc in Felton Aug 8 '12 at 9:54
    
After following instructions athttp://apple.stackexchange.com/questions/23751/how-to-turn-mac-os-x-lion-into-‌​a-web-server –  Marc in Felton Aug 8 '12 at 9:55
    
I am running PHP pages now. I'm having a problem accessing MySQL now, though... but I got PHP fixed! –  Marc in Felton Aug 8 '12 at 9:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.