PHP on Local Machine

Joined
Feb 9, 2005
Messages
842
Reaction score
10
Points
18
Hey, Im planning on working on a site in PHP in DW.

I was just wondering is there anyway that I can preview the PHP on my iMac locally rather than having to upload it to a web server everytime?

I've looked at XAMPP... would this do the job that I want and if so is it ok to just download this, intall and then run it in the background?

Heres the link to what I'm looking at
http://www.apachefriends.org/en/xampp.html


All help appreciated!
 
Joined
Jun 6, 2006
Messages
1,153
Reaction score
94
Points
48
Your Mac's Specs
MacBook 2.0GHz White, 512MB RAM, 60GB HDD
The built-in apache that comes with OS X has a PHP 4 interpreter, but it needs to be turned on by editing httpd.conf (in /etc/httpd/httpd.conf) to uncomment all the bits related to PHP (there should be three or four sections, just searching for 'php' within the file will find it). A tutorial is here: http://www.devarticles.com/c/a/Apache/Using-Apache-and-PHP-on-Mac-OS-X/

However, XAMPP provides a coherent whole so you don't have to worry about all that. There is a warning about it being in an early stage of development, but it's certainly the easiest way to get everything up and running.
 
OP
I
Joined
Feb 9, 2005
Messages
842
Reaction score
10
Points
18
The built-in apache that comes with OS X has a PHP 4 interpreter, but it needs to be turned on by editing httpd.conf (in /etc/httpd/httpd.conf) to uncomment all the bits related to PHP (there should be three or four sections, just searching for 'php' within the file will find it). A tutorial is here: http://www.devarticles.com/c/a/Apache/Using-Apache-and-PHP-on-Mac-OS-X/

However, XAMPP provides a coherent whole so you don't have to worry about all that. There is a warning about it being in an early stage of development, but it's certainly the easiest way to get everything up and running.

Thanks for the info.

Yeah I understand that it is in early stages of development but I don't think that I would be doing anything too major with it as I am just starting out with PHP.

So you think I should use XAMPP or just stick with the built in Apache?
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
If your not going to use any of the extras that XAMPP installs then I suggest you just try getting PHP working.
 
Joined
Mar 22, 2007
Messages
1,463
Reaction score
67
Points
48
Location
UK
Your Mac's Specs
Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
Get MAMP. Nuff said.
 
Joined
Jun 6, 2006
Messages
1,153
Reaction score
94
Points
48
Your Mac's Specs
MacBook 2.0GHz White, 512MB RAM, 60GB HDD
MAMP! I knew there was another one, but couldn't remember for the life of me what it was.
 
OP
I
Joined
Feb 9, 2005
Messages
842
Reaction score
10
Points
18
Yup, I'm using MAMP... its very effective. Straight forward too.
 
Joined
Mar 22, 2007
Messages
1,463
Reaction score
67
Points
48
Location
UK
Your Mac's Specs
Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
MAMP is great, it's easier than banging your head on something. And for Windows users there's a similar WAMP package that does the same thing.
 
Joined
Jul 6, 2007
Messages
16
Reaction score
0
Points
1
A tutorial is here: http://www.devarticles.com/c/a/Apach...P-on-Mac-OS-X/

I really want to get php working on my mac.
I followed the tutorial you suggested and get as far as
Use the following command in the Terminal.app:

sudo pico httpd.conf

but can't work out how to actually open the file or see any of the code I need to edit. Can anyone tell me where I go from here?
1.jpg


Hopingly, thanks
 
Joined
Jul 8, 2007
Messages
31
Reaction score
2
Points
8
Location
SLC, UT
Your Mac's Specs
Macbook Pro, 2.2Ghz, 4GB Memory, 120GB HDD, LCD Display, OS X Tiger
A tutorial is here: http://www.devarticles.com/c/a/Apach...P-on-Mac-OS-X/

I really want to get php working on my mac.
I followed the tutorial you suggested and get as far as


but can't work out how to actually open the file or see any of the code I need to edit. Can anyone tell me where I go from here?
1.jpg


Hopingly, thanks


It looks like you are not in the correct directory. Before typing "sudo pico httpd.conf" you have to type "cd /etc/httpd/" then type "sudo pico httpd.conf" and you should see everything. I bet right now if you look in you home folder you'll now have a file called httpd.conf, open it in TexEdit and it'll be blank.
 
Joined
Jul 6, 2007
Messages
16
Reaction score
0
Points
1
Yes, you're right. The httpd.conf file in my 'home' folder is empty. Its also called 'httpd.conf.save'
I've tried again in a different way and got to a window like this:
terminal_screen.jpg


I can find
#LoadModule php4_module
#AddModule mod_php4.c

but not
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

Even when I do a search for these, they do not show. Can you give me any clues what might be going wrong here? I'm wary of tinkering too much as I (quite clearly) don't know much about the UNIX side of things.
 
Joined
Jul 6, 2007
Messages
16
Reaction score
0
Points
1
Right, so now I find this in my httpd.conf file.

Code:
<IfModule mod_php4.c>
    # If php is turned on, we repsect .php and .phps files.
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
    # Since most users will want index.php to work we
    # also automatically enable index.php
    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

A # sign doesn't appear b4 the lines as I expected. Any ideas????
 
Joined
Mar 22, 2007
Messages
1,463
Reaction score
67
Points
48
Location
UK
Your Mac's Specs
Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
Are you using MAMP? If you're trying to get PHP scripts to run, it sets up all that stuff for you.
 
Joined
Oct 7, 2005
Messages
346
Reaction score
14
Points
18
Location
Seattle
Your Mac's Specs
MBP CD 1.83/2ghz/7200 100g + Mini 2ghz C2D 2gb + Mini 1.42ghz G4 + PM 7200/120 + Newton OMP
FYI, you might look into Quanta Plus once you're installed. It's a fantastic IDE for developing (amongst many other languages) PHP code. It was written for the KDE environment, but if you install Fink and then Fink Commander and then update the list of packages, Quanta will be one of them. It'll download all of the dependencies and compile everything. Depending on the speed of your machine, you might wanna do this over a weekend :)
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
A # sign doesn't appear b4 the lines as I expected. Any ideas????
The # sign is a comment field. It's absence means the lines are being used. That is a good thing.

Two other lines that need to have the # sign removed are
LoadModule php4_module libexec/httpd/libphp4.so
AddModule mod_php4.c

Oh yea. After editing the file, stop and then start Apache.
 
Joined
Jul 6, 2007
Messages
16
Reaction score
0
Points
1
Didn't we do this already?
I'm on 10.3.9 and MAMP is for 10.4
So you want me to dole out £90 for an upgrade?
D'you think I'm an applemacslave?Hate this planned obsolescence crap that mac (with their 'right on' marketing) try and suck us all in!

Yours
angry and confused.com
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top