Skip to main content
Inspiring
October 27, 2007
Question

Mac OS X Leopard and PHP

  • October 27, 2007
  • 19 replies
  • 1062 views
Posted in both the Dreamweaver and Dreamweaver Application Development
forums.

Mac OS X 10.5 (Leopard) uses Apache 2.2.6. This is NOT compatible with
the Mac PHP package recommended in all my books. Marc Liyanage
(www.entropy.ch/home) is aware of the problem, but there is no ETA for
an update.

If you have upgraded to Leopard and want to develop PHP pages on your
Mac, you might want to try MAMP (www.mamp.info/en/mamp.html) instead. I
haven't tested it myself yet, but it has a very good reputation.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
This topic has been closed for replies.

19 replies

Participant
December 28, 2007
For non nerds or starters like me:
To enable PHP and Apache in Leopard:

Apache is simple, go to the sharing panel in system preferences, and enable “Web Sharing”.

PHP requires he use of Terminal (or a BBEdit/Textwrangler if you prefer).

First check you have enabled Root in Leopard.

If not here’s how:

1. Open the Directory Utility: In the Finder, navigate to the Utilities folder (tip: click on the desktop, hit Cmd+Shift+U).
2. Click on the padlock to allow edits.
3. Go Edit > Enable Root Password
4. Enter and re-enter your password.

Now, you are set to access protected areas of the system via the terminal. Probably a good idea to back up any file before you modify it, just in case.

Back to terminal...
when you first start terminal it will show your Admin name followed by a colon,
eg johnsmith:

type “su” the press enter
terminal will the ask for a password,
type in your “password” and press enter.
Note your password doesn’t appear on the screen.

You have two files to alter briefly.

First file:

Type: sudo pico /private/etc/apache2/httpd.conf
and press enter (note the space after sudo and pico).

This opens the file: htpd.conf a hidden file.
Now if you haven’t used this before (I hadn’t and learned on the job), the navigation symbols at the screen bottom with an inverted “v” and a letter , mean to press control and the letter, for example “control X” to exit.

You need to alter 3 lines of code:

1....Use the arrow keys to move down the page...first find a group of coded lines that start with:
LoadModule (there are many lines)..
near the end you’ll find a line:
#LoadModule php5_module modules/libphp5.so

you need to remove the “#” to uncomment and make it active. Position the cursor to the right of the hash and press delete.

2....Next find a line starting with “DirectoryIndex” it probably looks like:
DirectoryIndex index.html

Alter it to this:
DirectoryIndex index.html index.html.var index.php


3....Next find a group of lines that have “ AddType application/x ........”
I seem to remember there were 2 lines like that,
add a line straight after like this:
AddType application/x-httpd-php .php ( note the space between php and .php)

To save your file press “control X” to exit, and “Y” (yes) to save. It then asks if you want to save as a name/different, I just pressed enter to accept the default name.

I went back to check all had been saved by re-opening the file.

Second File:

Type: sudo pico /private/etc/php.ini.default

You only need to alter one line n this file.
Look for a series of lines beginning with a semi-colon like this:
;error_reporting = etc etc etc

Find a line below without a semi colon like this:
error_reporting = E_ALL & -E_NOTICE

then edit out all after “E_ALL” so it looks like this:
error_reporting = E_ALL

Save you work as before.

You can now test PHP works quickly by starting TextEdit and type in:
<?php
phpinfo();
?>

Save the file as “test.php” to your root web directory
on my Mac is” Macintosh HD/Library/WebServer/Documents
(Actually I also saved it to just the WebServer folder).

Start up your browser and enter a URL: http://localhost/test.php

If all has been done as above you’ll get a ful listing of php stuff you probably don’t need to know!

October 31, 2007
same
Inspiring
October 29, 2007
jsteinmann wrote:
> Well, I can't create a connection to MySQL in Dreamweaver CS3... every time I
> try it crashes. WIthin terminal, it says MySQL is running, and I can show
> databases so it's there... I just can't create a connection.

I haven't tried connecting with Dreamweaver yet. I've been up to my
eyeballs in lots of other things. I'm not sure when I can get round to
it. If you look at a lot of the threads here and in the other DW forum,
an apparent clock change bug is making life a misery for Windows users,
including me (I use Mac mainly for testing purposes).

It's possible that MySQL will need to issue a Leopard build. They needed
to do so for all previous Mac OS upgrades.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
October 29, 2007
Well, I can't create a connection to MySQL in Dreamweaver CS3... every time I try it crashes. WIthin terminal, it says MySQL is running, and I can show databases so it's there... I just can't create a connection.

This is the Mac OS X 10.4 (PowerPC, 32-bit) package format download.
On the MySQL site, some other people are complaining it's not working as well.
Any suggestions?
October 31, 2007
I cannot connect to MySQL 5.041 through DW CS3 after upgrading to Leopard. MySQL Admin and MySQL Query Browser both can connect and make queries to the database. I just can't connect through Dreamweaver. I get the "MySQL Error#: 2002" error which states "Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2). Problem is there is no such path.
Inspiring
October 28, 2007
David Powers wrote:
> I've been struggling with php.ini all afternoon. It appears that the
> only way to copy and rename it in OS X is to enable the Mac root user.
> Using sudo doesn't have sufficient privileges.

It turns out that sudo is sufficient after all. I got the idea about the
need for root user from an old article by Drew McLellan. However, other
simple operations weren't being performed, so I restarted my computer,
and suddenly everything is working again.

It's easy to see how bad information gets spread unintentionally. I had
problems, picked up an idea from what I thought was a reliable source,
and passed it on here and in my blog. For all I know, the information
might have been correct at the time Drew posted it, but it's no longer
applicable. When I've got everything sorted, I'll post detailed
instructions on my site.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
October 28, 2007
I was going to say, I didn't have nearly the trouble it sounds like you were having, but it's probably because I didn't know any better either. Keep me posted if you learn new things or add-ons... but fore development purposes I'm pretty well set. Only thing I'm waiting on now it MySQL.
Inspiring
October 28, 2007
jsteinmann wrote:
> Thanks for the heads up about php.ini.

I've been struggling with php.ini all afternoon. It appears that the
only way to copy and rename it in OS X is to enable the Mac root user.
Using sudo doesn't have sufficient privileges.

> I have to say, having just installed PHP5 on a windows 2003 server, this
> really wasn't that bad on OSX. PHP has a good community so you usually get
> answers pretty fast.

It's very easy to get PHP 5 running on Leopard. However, it's not a
fully featured version. It doesn't read a configuration file, and the
default file is inaccessible to an ordinary admistrator. Moreover, if
you want any extra features or to upgrade to a newer version, you need
to compile it yourself. I've succeeded only once in compiling PHP on Mac
OS X. If anything goes wrong it's a complete nightmare.

By comparison, installing PHP on Windows is a breeze. There's an
official Windows installer, or you can use the zip version. It's always
available the same day as the *nix release. Unfortunately, there's no
official binaries distribution for Mac OS X. Mac users have a
considerably tougher time. I test PHP on a Mac only for the benefit of
readers of my books. Otherwise, I wouldn't bother. The hassle over the
years has been too great.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
October 28, 2007
jsteinmann wrote:
> I heard of some people running into issues like that because the did an
> Upgrade install so they had 2 versions of apache running at the same time...
> which is always a bad idea. I never do Upgrade installs because it's just
> asking for trouble... always Erase and Install with the new OS.

It's not surprising that most people do upgrade installs, because that's
the way that Apple does it by default. You don't end up with two
versions of Apache running, but you do have the legacy files of Apache 1.3.

At some stage, I'll probably get round to doing a completely clean
install, but it's a major hassle to move all your files, and then
reinstall every single piece of software.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
October 28, 2007
Thanks for the heads up about php.ini.

I have to say, having just installed PHP5 on a windows 2003 server, this really wasn't that bad on OSX. PHP has a good community so you usually get answers pretty fast.
October 28, 2007
That's strange people are having trouble with personal Sites folder... I didn't have that problem.

I heard of some people running into issues like that because the did an Upgrade install so they had 2 versions of apache running at the same time... which is always a bad idea. I never do Upgrade installs because it's just asking for trouble... always Erase and Install with the new OS.
Inspiring
October 28, 2007
jsteinmann wrote:
> By the way, I've heard this is nice way to simplify things and get people up
> and running very quickly to develop in PHP/APACHE/MySQL
>
> http://www.apachefriends.org/en/xampp.html

XAMPP is fine for Windows (and Linux, I think). To quote the XAMPP site,
the Mac version is "in the first steps of development. Use at you own
risk!"

A reliable all-in-one solution that works on Leopard is MAMP
(www.mamp.info/en/mamp.html). I tested it yesterday, and it seems fine.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/