Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bmcgonag

macrumors 65816
Original poster
Mar 20, 2007
1,077
0
Texas
I installed PHP (latest version) and MySQL (same) as some tutorials instructed from online, and I don't know where to put the index.php file now on my iMac to view it in a web page on my local machine.

I tried it in the /Library/WebServer/Documents, no luck, just displays the code...

tried it in my home Sites folder, same thing. Any help is appreciated.

Do I need to start PHP?

Brian
 
First, turn on the Personal Web (Start) preference in System Preferences -> Sharing. Once you start the Personal Web, it will tell you your local IP address.


Then put the file in ~/Sites/<some_folder>/. You should then be able to view it at either:
http://localhost/~<Your_Username>/<some_folder>/index.php
or
http://1.2.3.4/~<Your_Username>/<some_folder>/index.php

You can use the /Library/WebServer/Documents/ folder if you do not want it to be in your home directory.
 
First, turn on the Personal Web (Start) preference in System Preferences -> Sharing. Once you start the Personal Web, it will tell you your local IP address.


Then put the file in ~/Sites/<some_folder>/. You should then be able to view it at either:
http://localhost/~<Your_Username>/<some_folder>/index.php
or
http://1.2.3.4/~<Your_Username>/<some_folder>/index.php

You can use the /Library/WebServer/Documents/ folder if you do not want it to be in your home directory.

I did exactly that....but when i type in the url (basically http://127.0.0.1/index.php or http://127.0.0.1/~myhome/index.php) it just shows me the php code on the page, it does not render the page in the browser.

I don't know what i'm doing wrong, but i need to do something to get it to render the page in the browser window.

Brian
 
Sounds like php is disabled. You can enable it by editing the httpd.conf file located in /etc/httpd/ and removing the # in front of php.

This should point you in the right direction:


Enabling PHP


As for running the latest version, you're on your own there, but this will give you an idea..
 
Sounds like php is disabled. You can enable it by editing the httpd.conf file located in /etc/httpd/ and removing the # in front of php.

This should point you in the right direction:


Enabling PHP


As for running the latest version, you're on your own there, but this will give you an idea..

Perfect, it's working great! thanks

Brian
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.