Working with PHP 5 in Mac OS X 10.5 (Leopard)
October 28th, 2007
Mac OS X is a great development platform for working with PHP. Leopard comes with Apache, PHP and many other development tools, such as subversion already installed. Leopard brings a much needed upgrade from Tiger's tired PHP 4 to a very modern version of PHP 5.2.4. This is a guide for setting up a PHP development environment under 10.5 using the version of PHP that ships with leopard.
You may prefer to use one of the 3rd party distributions of PHP, such as MAMP, XAMPP or Marc Liyanage. This is a guide to using the version of PHP that comes with 10.5.
Enable Developer Tools
These steps may not be strictly necessary for this process, but I find it useful to do them.
First, enable your root password.
You may also want to install XCode Tools from your Leopard disk (or grab the latest from Apple developer tools). The tools are required is you are going to compile any extensions for PHP.
Editing Configuration Files
We will have to edit several configuration files that exist as part of the unixy underpinnings of OS X. I'm going to recommend the free text editor, TextWrangler for this purpose. Normally, the finder hides the configuration files from view. However, in the finder, you can use the "Goto Folder..." option under the "Go" menu to view these files. This option if available via command-shift-G. Actually, this option is available in any file open dialog in OS X via command-shift-G. In addition, Text Wrangler will allow you to browse these files with its "open hidden..." option. But, the much easier option is selecting "Open file by name..." (command-D) and just typing the full path and filename. To save many of these files, you will need to enter your root password. Be Careful.
Enabling PHP
PHP is installed in Mac OS X by default, but not enabled. To enable it, we must edit the apache 2 configuration file, which is located at /etc/apache2/httpd.conf. Find the line which loads the PHP 5 module, which looks like this:
#LoadModule php5_module libexec/apache2/libphp5.so
The line is currently commented out. All we have to do is remove the comment symbol, #, so the line looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Save.
Starting Apache
Go to the sharing panel in system preferences and enable "Web Sharing." This will start the apache server.

Another way to do this is to type the following in the Terminal application:
sudo apachectl start
You will be prompted to enter your root password. After that, your apache server should now be running. If you need to restart the server from the terminal, you can type this:
sudo apachectl restart
If you find this tedious to type, there is a script that you can download to do this later in this post.
Visiting our Web Site
Now, lets check our work. In the sharing panel, you can click on the URL under "Your computer's website." Alternatively, in the web browser, go to the url http://localhost/. localhost is a special name that means "My computer." If your web server is working, you should see a page titled "Test Page for Apache Installation." If you go to http://localhost/manual/, you can read an Apache 2.2 manual, hosted from your own server. But, this don't tell you that PHP is working.
For that, we'll have to create a very simple php program. Create a new file in TextWrangler and type the following:
< ?php phpinfo(); ?>
(Don't just copy and paste this. Note that there should be no space between the < and the ?php. The WordPress software I use for this blog inserts an extra space.)
Save this using the file name info.php in the /Library/WebServer/Documents/ directory. (start from the top level directory of your hard drive, not the library directory in your home directory. Now you should be able to visit the PHP page you just created by visiting http://localhost/info.php. You should see the PHP logo and a big table of configuration information.
Showing the World
For security purposes, you should consider that anything you put in your WebServer/Documents folder will be available across the web. If you have information that you want to keep private, think twice about putting it there, unless you know how to protect it.
But, if you want people to see the pages that you are sharing, there can be a few obstacles. You can give out the URL that is listed in the sharing control panel under "Your computer's website." However, if you are behind a NAT router, such as I am, this IP address based url will only work for other computers on your network and not for the internet as a whole. You may have to configure network router or firewall in order to discover your true ip address and to route web server requests to that IP to your computer. Doing this is beyond the scope of this tutorial.
Additionally, IP address based urls don't make good urls to share. IP addresses can change. If you plan to host a permanent web site, you may want to purchase a domain name and point it to your Mac. This also, is beyond the scope of this tutorial.
Perhaps the best option is to purchase both a domain name and professional hosting. Apache based PHP Hosting is widely available and cheap. You can get support from a good host on uploading your files to the remote server. I'm going to presume that you will use one of the many excellent PHP hosting options and are only configuring PHP on your own machine for education, testing or development purposes.
Enabling a Personal Website
If you clicked on the URL under "Your Personal Website," you might have gotten a page that says forbidden. This is because in the default configuration in Leopard, unlike in Tiger, does not allow Apache to serve documents from home directories. If you want to enable this feature, you have to create a new Configuration file.
Create a new file with the following contents and save it to /etc/apache2/users/jeff.conf.
<directory "/Users/jeff/Sites"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </directory>
Replace "jeff" with your user name, which is also the name of your home directory. Exact capitalization is imporant. This tells the Apache server that it is ok to serve web content out of the ~jeff directory. You will have to restart Apache for this to take effect.
You may also have to create a Sites folder in your home directory to hold the files you want to serve. Leopard will automatically bless this folder with a special Icon.
Virtual Hosting
If you want to experiment with or work on more than one site at a time, the single directory in WebServer Documents and the Personal Websites configuration don't work well. Projects collide and files outside of your home directory can be harder to work with. The answer to this is to setup virtual hosting. Lets turn our Personal Website sharing solution into a virtual hosting solution that allows us to work with multiple websites as subdirectories of our Sites folder.
So, lets create a sample site, called mysite. We'll create a folder called "mysite" as a sub folder of our Sites folder. Capitalization is important.
Now, we are going to want to access our site with an easy to use domain name, so that our url is http://mysite/. There is an easy way to create new domain names that are only for personal use. To do this, we can add it to our /etc/hosts file. Add the following lines at the end of this file:
# My local aliases
127.0.0.1 mysite
127.0.0.1 is a special IP address designation that never changes and corresponds to localhost to mean this computer. We are telling our Mac that the name mysite is hosted on the local computer. This rule is only in effect on the same machine. If you go to a different machine, you cannot use the http://mysite/ url.
Now we need to configure apache for virtual hosting. We are going to have to edit our /etc/apache2/users/jeff.conf file. Change the contents of this file to the following:
<directory "/Users/jeff/Sites/*/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </directory> NameVirtualHost *:80 <virtualhost *:80> DocumentRoot /Users/jeff/Sites/mysite ServerName mysite </virtualhost>
Remember to replace "jeff" with your user name. Place your info.php test file into the mysite directory and rename it to index.php. Now, restart your apache server. When you visit http://mysite/, you should now see the familiar php logo and information page.
If you want to add another site, just add a second line in your hosts file, another subdirectory of Sites and append the following to your apache configuration file:
<virtualhost *:80> DocumentRoot /Users/jeff/Sites/myothersite ServerName myothersite </virtualhost>
Sharing with the World, Part II
Sharing your virtual hosted sites with the world is more complicated if you don't have a domain name setup. You can, however, add your hosts files entries to other computers that you want to share with. However, you have to change the 127.0.0.1 IP address to the IP address of your computer, taking into account any NAT.
There is a special case of this. If you are using parallels, perhaps for test viewing your pages in internet explorer, you may want your virtual hosted sites to be available. The good news is that Windows also supports a hosts file. Here is how to edit your windows hosts file. The big problem is knowing what IP address to use. You can't use 127.0.0.1 on the windows side because that is the virtual windows machine, not your Mac's address. You can use the IP address shown on your network system preferences panel, 192.168.1.100 for me. But, this number is subject to change and you will have to re-edit your hosts file on the windows side.
If you are using Parellels, be sure to upgrade to the new beta version for Leopard, build 5540. Once you've done that, if you visit the network panel in system preferences and select the "Parallels Host-Guest" network, you will see the IP address that parallels assigns to your host machine. (assuming you are using Shared Networking.) You can then use this IP address in your windows hosts file. You may also be able to change "Using DHCP" to "Using DHCP with Manual address" and re-entering this number if you have a problem with the number changing. Here, my number is 10.37.129.3:

Installing MySQL
MySQL has a binary distribution for Mac OS X. They also have reasonably good documentation on installing MySQL on Mac OS X for their distribution. Note that Leopard specific packages for MySQL have not been created yet.
Starting MySQL
So far, the MySQL preferences panel from the Tiger release is broken and does not correctly start and stop MySQL (bug report. You can do this from the terminal window with
sudo /usr/local/mysql/support-files/mysql.server start
To shutdown the server type:
sudo /usr/local/mysql/support-files/mysql.server stop
If you find this tedious to type, you can download WebDevCP, which is a small AppleScript application that I made. Launching WebDevCP launches both Apache and MySQL. Quitting the application shuts them both down. usually. Launching and quitting requires a password. No warranty on this thing. It was just something I was using personally and figured others might find useful.
Bring the mysql.sock to PHP
One problem that has come about with MySQL and Leopard is the location of the mysql.sock file. Previously, the default location for this file was in the /tmp directory. That location has now moved to the /var/mysql directory. PHP will look for it there. Unfortunately, the default location from the MySQL will still place it in the old location. We can fix this by creating a my.cnf configuration file in the /etc directory. Save a file with the following contents to /etc/my.cnf:
[client]
socket = /var/mysql/mysql.sock
[mysqld]
socket = /var/mysql/mysql.sock
In the terminal window, type the following commands to create the directory for the sock file:
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
One drawback to this is that if you have installed the MySQL GUI tools, they will look for the mysql.sock file at the old location. You can enter the new socket in the connection dialog under More Options, there is a box labeled "connect using socket." Just enter /var/mysql/mysql.sock.
Another solution is to change the php.ini file to expect the socket in a different location. I'm going with the my.cnf option because I expect the MySQL will have a Leopard version out in a few days that changes the default location.
Where is PEAR?
OS X has traditionally had problems with PEAR. Many point updates would overwrite the included version of PEAR with an older, and perhaps insecure version. Sadly, Apple has fixed this by not including PEAR at all in their OS. This is a big inconvenience for people wanting to use Apple's default version of PHP, versus a third party distribution. So, lets get PEAR installed. Type the following in the terminal window to download the PEAR installer:
curl http://pear.php.net/go-pear > go-pear.php
after that, type
sudo php -q go-pear.php
To run it. Hit enter to select the default locations. PEAR will be installed, but it won't be ready to use until we modify our php.ini file.
PHP .ini configuration
Now we need to make some changes to our php configuration file. Leopard has an empty configuration file by default, but provides a file which you can use as a template. From the terminal window, type:
sudo cp /etc/php.ini.default /etc/php.ini
Now, edit the /etc/php.ini file. Find the include_path setting:
;include_path = ".:/php/includes"
And change it to
include_path = ".:/usr/share/pear"
This enables our PEAR installation. You may also want to make some changes which will improve your ability to debug PHP. FInd the line that says
log_errors = Off
and change it to
log_errors = On
You have to then restart Apache for these PHP changes to go into effect.
Errors and Omissions
Thats all there is to using the version of PHP delivered with OS X. If you find this confusing, you are probably better off with something like XAMPP or MAMP. I'll probably end up compiling my own versions of PHP, but that is a different blog post. I've already had problems with this configuration when I tried to install XDebug via PECL. One last thing, if you run into problems, you can check the apache2 error_log file using the Console application.
For support, try the Sitepoint forums or Apple's Discussion Forums.
October 28th, 2007 at 7:33 pm
A very good walkthrough, covering every stumbling block I found while playing with Leopard this weekend except one. Apple's default install uses PDO, but only includes drivers for SQLite and SQLite2 - no PDO_MySQL, despite having both the MySQL and MySQLi extensions. I ran into the aforementioned pecl trouble, so I haven't gotten the pdo_mysql driver installed yet. My time's up for playing with 10.5 for a few days, but If you find a working patch for this, that may be a good thing to add to your tutorial. I'm sure it will be a common problem.
October 28th, 2007 at 10:40 pm
I had various problems with the /etc/hosts file on OS X 10.4, but as it turns out there is an alternative less traditional way Apple does (did?) things, using the netinfo manager.
October 29th, 2007 at 4:37 am
Because of the PDO MYSQL issue above, I tried to build my own version of PHP5, but ended up with a missing symbol to do with the XML library. Has anyone managed to build PHP5 successfully for Leopard? If so, care to share the trick?
October 29th, 2007 at 6:28 am
Yep, Tiger could use netinfo, but apparently Leopard has deprecated netinfo and the netinfo manager is no longer installed.
October 29th, 2007 at 8:25 am
I would like to add the "dbase" extension to the PHP installation on Leopard. Can I do that if I follow this method? If yes, How?
October 29th, 2007 at 9:42 am
Great post--this bugged me all weekend after my Leopard upgrade broke my Virtual Hosts... I miss NetInfo. The only tweak I'd recommend is to let people know to change their permissions on the example. I had to use
chmod 755 mysiteandchmod 755 *(inside the mysite directory)to get my sample page to show.
Thanks for the instructions, this has been a big help
October 29th, 2007 at 10:01 am
This is widely reported. During the upgrade process, apparently Apple's scripts don't properly account for the fact that /private/etc/httpd/users/ has now become /private/etc/apache2/users/ and fail to move the old user accounts to the new location. Simple fix, drag the files to their new home. Editing the accounts might trigger new file builds as well. New installs of Leopard don't have this trouble.
October 29th, 2007 at 1:17 pm
Thanks for this! Quick lifesaver.
October 29th, 2007 at 1:30 pm
Thanks for all this instruction.
Do you know what happened to pear DB? Previous to installing Leopard it was in /usr/lib/php/DB.php, now ??? The pear installation above doesn't seem to include DB - just MDB2.
Please forgive my ignorance.
October 29th, 2007 at 1:45 pm
I just saw that DB is suspended. I will install the package for my older projects... Thanks.
October 29th, 2007 at 2:57 pm
Your article is really good. Except for two small problems.
October 29th, 2007 at 3:54 pm
I'm glad this post is proving useful.
Lonnie, I've updated the post to correct some typos and incorporate your two problems.
Additionally, I've updated the Section on Parallels networking on how to discover the IP address of your Mac.
In a couple days, I'll probably have a post on how to compile PHP from scratch under Leopard and add extensions such as XDebug.
October 29th, 2007 at 9:38 pm
Looking forward to your directions for compiling, I've not had any luck due to problems with the mysql bindings.
October 30th, 2007 at 7:41 am
In order to get PHP to compile and run on OS X 10.5 you will need to do a couple of thin gs...
First, if you want mysql support in your build - install the binary from mysql's website and then do the following:
sudo mkdir /usr/local/mysql/lib/musql
sudo ln -s /usr/local/mysql/lib/libmysqlclient.15.0.0.dylib /usr/local/mysql/lib/mysql/libmysqlclient.15.0.0.dylib
sudo ln -s /usr/local/mysql/lib/libmysqlclient.15.dylib /usr/local/mysql/lib/mysql/libmysqlclient.15.0.0.dylib
sudo ln -s /usr/local/mysql/lib/libmysqlclient.dylib /usr/local/mysql/lib/mysql/libmysqlclient.15.0.0.dylib
Then, you will need to download the apache2 source. Apache2 needs to be recompiled because of an architectural error when compiling php. I've been unable to resolve this error by compiling PHP as a universal binary, so rather then waste anymore time apache is easy enough to compile we'll go ahead and just do that.
./configure --enable-layout=Darwin --enable-mods-shared=all && make && sudo make install
Note, this install overwrites the existing 10.5 install. The upside of this is that it can be controlled via the Sharing Preferences.
Then you should be able to compile PHP with apache2 just fine. If you want the newly compiled php to overwrite the existing one be sure to set --prefix=/usr otherwise set --prefix=/usr/local
If you have any questions or want to know about compiling PHP with gd support feel free to drop me a line.
Pax.
October 30th, 2007 at 10:40 am
Is it possible to add postgresql support to the apple version of php? I'm about ready to give up on trying and just install my own copy of php and apache.
October 30th, 2007 at 4:29 pm
Great post! I love programming with my mac. It's so much faster, and php is great to be programmed on a mac.
October 30th, 2007 at 6:59 pm
Very nice page.
But unfortunately I ran into a problem when trying to install pear.
(1)$ sudo php -q go-pear.php
dyld: NSLinkModule() error
dyld: Symbol not found: __zval_ptr_dtor
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/libpdf_php.so
Expected in: flat namespace
Trace/BPT trap
What might I have done wrong?
October 31st, 2007 at 9:31 am
After upgrading to Leopard on the weekend I was madly searching the internet to get info on how to get my testing environment functional again.
There are lots of sights with pieces of info, but this is far and away the best resource I found for getting your Apache, PHP and MySQL functional after upgrading to Leopard.
Thanks for your detailed work!
October 31st, 2007 at 1:26 pm
Thanks for the walkthrough! Saved me hours of stumbling around...
October 31st, 2007 at 4:40 pm
thanx so much for posting this. what a lifesaver! went through created the user conf files, changed the path to wordpress blogs and bob is your uncle - everything work like a charm. back in business.
many thanx for sharing this information. sending you a virtual beer!
October 31st, 2007 at 6:26 pm
@Rainer
It isn't a problem with the go-pear script, it's a problem with the libpdf_php.so module. I've tried to install XDebug & pdo_mysql and I get similar errors. even doing php -v on the command line will give you the same error. Weird thing is that running a simple script like
will run just fine and show the installed modules, but any semi complex script, or anything on the cli will fail, even if it doesn't actually call the custom module.
For now if you comment out the libpdf_php.so module in your php.ini, pear should work.
Hopefully someone will figure out the trick to compiling modules soon.
November 1st, 2007 at 9:52 pm
This will be helpful to some folks:
Migrating MySQL 5.0.45 to Mac OS X 10 .5 Leopard http://blog.tomatocheese.com/archives/2007/11/1/migrating_mysql_to_mac_os_x_leopard/
November 1st, 2007 at 10:48 pm
Ran into the problem of trying to recompile PHP on OSX 10.5 Server when trying to add pdo-mysql. I too couldn't resolve the arch type errors. Thought about going with the recompile of apache2 route, and even got as far as ./configure && make, but didn't do the make install because I noticed that the configure script identified the system as i386.
... Now I know one of the big deals about 10.5 is that most (or all) of it is 64bit from the ground up. Including things like apache2 and mysql. I was able to muck around with the Makefile and get it to target i686, but how can be sure that it's compiling apache2 as a 64bit binary?
I'm slightly less concerned about replacing apache2 with a 32bit binary on my MacBook Pro... but on a Xserve with apache2 being used for all the iCal CalDAV and wiki and webmail stuff, I'm a little more hesitant.
November 2nd, 2007 at 1:42 pm
Thanks for your advice. With some diddling around, starting and stopping, etc. I got my personal web server working again and my Mantis problem tracker going as well as the cvs viewer again. I am still having problems with getting a perl script that used to run under cgi-bin working. Obviously there is more to fix.
Thanks.
November 2nd, 2007 at 9:16 pm
These instructions are great and helped me get my development coding environment back on track. I thought I was going to have to spend weeks trying to get my computer to run Apache, PHP, and MySQL the way I had them running with Mac OS X 10.4 but I was able to get things running in a couple of hours with these instructions.
Much appreciation goes to the person whom wrote and/or gathered all of this information.
November 2nd, 2007 at 9:43 pm
Thank-you so much for posting these solutions!!
I am very new to PHP, MySql and Apache and this page was a great help. I couldn't find any other information on how to get things working in Leopard.
November 4th, 2007 at 12:36 pm
Looks Like we can't compile extensions under the Apple-supplied PHP:
http://netevil.org/blog/2007/11/php-objective-c-bridge
Hopefully Marc over at entropy.ch will get the Quad-binary thing solved soon...
November 4th, 2007 at 1:44 pm
Thanks, has helped to transfer to leopard...
One remaining problem is that i can not access the virtual hosts from parallels. Windows always goes to the localhost directory location on the mac.
My virtual hosts do not specify a port number, just a name and a different directory location. Works on the mac site, not on the pc site... I set all virtual server names to point to Parallels Host-Guest ip the in the windows host file...
November 4th, 2007 at 4:05 pm
Just a quick note...I've spent the weekend trying to get this to work...obviously I'm not as technically adept as most of you guys, and as a recent Mac convert, not as familiar with the Mac yet either.
Here's how I was able to get parallels to work so I could test my sites in IE. I installed Bonjour for Windows in my VM, then I could access my webserver running on my mac by using the URL http://macleemo.local (my mac is MacLeemo). I was then able to see my Joomla sites in both my Mac and parallels!
Thanks for the great tutorial!
November 4th, 2007 at 5:20 pm
Just wanted to say, this was uber helpful. Annoying how Leopard doesn't allow Apache to serve documents from home folders. Its been buging me for days.
Cheers.
November 5th, 2007 at 2:04 am
Do you know how to add the GD libraries to PHP under OS X.5 leopard??
I used to use Mark Lyanages packages for years and they came complete with that. Easy one-step installation which even restarted Apache when installing. . . . but I dont know enough about Compiling it myself to add GD image library support to PHP under Apache 2.
Any detailed info would be GREATLY appreciated.
THanks!
November 5th, 2007 at 4:03 am
I stumbled across this article, and I'm glad I did.
I always knew that apache was built into OS X, but I never knew that PHP was too. Up until now I've been using MAMP for all my development, but I reckon I will try and get rid of it now if I can MySQL to install and play nice!
Thanks a lot.
November 5th, 2007 at 11:04 am
Thanks! this post was a lifesaver
November 6th, 2007 at 11:13 am
As for the pdo_mysql issue, that is nagging me too, if found this message here: http://discussions.apple.com/thread.jspa?messageID=5669164�
Haven't tried it yet, but this seems to be the easiest and fastest way.
November 7th, 2007 at 4:12 am
Jeff, thank you for this clear instruction. Where are you with rebuilding PHP? Do you also have to rebuild Apache and Mysql? I am waiting for this new instructions, especially about XDebug...
...
November 11th, 2007 at 5:56 am
Hello, your topic is very interesting, and I have now a complete installation on my os 10.5, BUT, it is absolutely impossible to install a GD2 library, necessary for my business (building websites with Spip) ...
I have download the php5 Liyanage package, but I dont know to enable this, Apple's Apache2 is always reading his own php5 ...
If you have a solution, I will be very happy ... and excuse my english, I am writing from Paris (France)
Thanks a lot ... Marc
November 11th, 2007 at 7:24 am
I haven't done my from-scratch compilation of PHP on leopard yet, but it looks like that is the way to go if you want to use certain extensions. Meanwhile, I ran into a post on building mysql for os x.
November 13th, 2007 at 6:32 am
Why does it appear to be so difficult to use PHP on Mac OS X? Is there no such program like MAMP for Mac? Like there's LAMP for Linux and WAMP for Windows.
Friends at TalkPHP.com!
November 13th, 2007 at 11:12 am
@Rainer
probably your /usr/bin/php is hosed
If like me, you have installed Entropy or Zend or both, try the complete path on the command line.
# /usr/local/php5/bin/php -v
or
# /usr/local/Zend/Core/bin/php -v
When you decide which you want:
# cd /usr/bin
# ln -s php
I linked both php and php-config to my entropy php and it is working so far. My pear was broken also and is now working again.
Pretty sure this is not the best way, like if Apple updates your default php the links should get overwritten, but it works for now.
November 13th, 2007 at 11:16 am
Sorry
#ln ---one you want--- -s php
I used XHTML tags to mark the text after ln on the earlier post, and of course the text and tags disappeared.
November 22nd, 2007 at 6:27 pm
I have many trouble installing PHP on my MAC. I have given up. I'm gonan give this tutorial shot and see what happens. Thanks for the tutorial thou.
November 26th, 2007 at 6:47 pm
Anyone know how to get phpmyadmin up and running in combination with this tutorial.... i keep getting an "access denied for user 'root' @ 'localhost' (using password: NO) message.... have no idea what to do from here.... i have php and mysql running fine... this is the last piece i need
November 27th, 2007 at 8:03 am
@ Joshua
You need to go into the phpMyAdmin directory and rename (make a copy) the config.sample.inc.php to config.inc.php. In the First Server section, fill in the required settings:
Works for me so far...
Miles
December 4th, 2007 at 4:00 pm
Thanks to the authors for putting this tutorial together. It was very helpful in getting me up and running with Apache 2 and PHP 5 on Mac OS X Leopard. One thing that I did not find in this tutorial that I had to do was to edit the "Document Root" and "Directory" commands in Apache's httpd.conf file to point to my Sites directory. A mention of this would be nice.
December 13th, 2007 at 9:21 am
I have successfully got apache and php running on Leopard, however I'm having an issue with mySql. I get the following error in the terminal when running:
sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
December 13th, 2007 at 1:44 pm
Great and
veryuseful article! Thank you!December 16th, 2007 at 4:07 pm
Hi, first of all thanks for this great tutorial. Everything works great!
Except for Rails. Going, through terminal to create class instances into the database tables, it puts out this error message:
>> story = Story.new
Errno::ENOENT: No such file or directory - /tmp/mysql.sock
It goes looking for the mysql.sock to the default location, but having changed it to the var directory it doesn't find it.
How can we solve it?
Thanks anyone for the help.
December 16th, 2007 at 9:03 pm
what do I do once I've installed go Pear? I don't know how to list the available packages. Could someone give me the next step. The last thing I did (from above instructions) was change:
include_path = ".:/usr/share/pear"
If I look in /usr/share there is no pear folder in there.
December 19th, 2007 at 2:27 am
Thanks a lot buddy. Worked very well. Just perfect.
December 29th, 2007 at 1:16 am
You can install a completely different set of LAMP on OS X using Mac Ports.
January 8th, 2008 at 8:30 pm
Thanks a bunch for your time on this - helped my a great deal, everything fell into place as described. Muchos!
January 22nd, 2008 at 6:20 pm
Another solution for mysql.sock, that works for me:
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
January 22nd, 2008 at 6:23 pm
Another solution for mysql.sock that works for me:
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
February 9th, 2008 at 3:24 pm
I had installed on 10.4 the php package from Entropy, which installs php in /usr/local/php5
I simply upgraded my box to 10.5 and slogged thru the issues.
What I didn't ponder was this.
Since php is installed as part of 10.5, where is this installed version of PHP? That is, where is the native version of php installed at?
February 11th, 2008 at 2:32 am
how about viewing the error_log on local.... anybody who has an idea?
February 12th, 2008 at 4:30 pm
Hi and thank you for the info setting up Apache in Leopard was a pain in the ass until I found this site. One question what do I create a new Configuration file in? Do i use test wrangler or something else? Thanks for all the help and info it is a life saver!
February 21st, 2008 at 8:19 pm
Hi Guys,
I have followed all the instructions and was able to uncomment the line to enable php. I then created the info.php file and saved it.
When I open the browser and got http://localhost/info.php I see the actual text in the browser
eg: i see this in the browser.
Another php file i created does the same. Is there any reason why I see text, not the result of phpinfo()?
Any help would be great.
February 21st, 2008 at 9:41 pm
Forget my above post. I just didn't restart the web sharing after uncommenting the line in the apache config file.
Cheers,
Michael.
February 22nd, 2008 at 6:30 pm
Stifo gets the platinum star for Post 84...it was the only thing that worked for me!
Thanks, dude!
February 23rd, 2008 at 8:59 am
Thank you for your work. You have a very readable manner of writing, easy to follow, not too much info and not too little. Thanks.
February 26th, 2008 at 4:49 am
Thanks for the instructions, it really helps me
February 27th, 2008 at 11:16 am
For GD and possibly others that were left out, check out:
http://docs.moodle.org/en/Step_by_Step_Installation_on_a_Mac_OS_X_10.5_Server#Install_the_GD_Library_on_the_Mac_OS_X_10.5_Server
March 1st, 2008 at 10:44 am
everything was working fine until i tried setting up the personal web site and every time of put “http://mysite/” i got the following error message - afari can’t open the page “http://mysite/” because it could not connect to the server “mysite”.
And i can't work out what's wrong - i am very much a novice at this stuff HELP HELP
Keith
March 3rd, 2008 at 10:34 am
Thanks for the hints
One drawback to this is that if you have installed the MySQL GUI tools, they will look for the mysql.sock file at the old location. You can enter the new socket in the connection dialog under More Options, there is a box labeled "connect using socket." Just enter /var/mysql/mysql.sock.
You can also enter 127.0.0.1 instead of localhost. Also some other applications will got no connection to MySQL using localhost, but when using 127.0.0.1 all works fine.
March 15th, 2008 at 3:42 pm
Hi.
Is there someone with a precompiled executable for php-cli 5.2 for OSX leopard with GD included.
I mean the executable under /usr/bin/php about (13Mb)
I would be very thankfull if someone could mail this to me.
jago (at) jago.se
Regards Jago Svensson
March 17th, 2008 at 7:44 am
I've downloaded and installed a Pecl extension, and when I try to run PHP (from the command-line) with the extension enabled, I get the following error:
dyld: Symbol not found: _zend_register_long_constant
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20060613/id3.so
Expected in: flat namespace
and I don't know how to go about compiling the extension from scratch to try to figure it out.
I've installed Pear, and it works fine. I've done this before, I know how and what to edit in php.ini.
OS X 10.5.2, PHP 5.2.4, Zend Engine 2.2.0
Anyone? Sorry, but this is annoying, and no one seems to know how to fix it.
March 18th, 2008 at 8:00 am
I have the same problem as someone above. I did this and there is no pear in
/usr/share/pear
the only pear I find is in:
/private/var/root/bin/pear
any idea why it ended up there? I have root enabled and did the whole sequence of events under su command (logged in as root).
March 18th, 2008 at 11:29 am
@RichSad, reply #103
When you ran go-pear, you were presented with a screen that showed you where it was going to place the stuff. If you were logged in as root, then root's home directory is /var/root and if you just hit the "enter" key, you instructed go-pear to install the binaries for pear and pecl in /var/root/bin, which is go-pear's default which is relative to where it's called from.
To run these binaries in place you can log in as root and run
bin/pear
bin/pecl
and so on.
I like this well-written set of instructions, but I think that telling novice users to work as root is a mistake. Anyway, I think you should move the binaries into some place that's in your $PATH as a non-root user.
March 30th, 2008 at 9:07 am
It seems that after last Leopard security update 2008-002 my custom php installation (which replaced system one) stopped working. The php binary was replaced and it doesn't load gd.so and mysql.so modules anymore.
I tried to recompile and reinstall php again but it breaks on linking, claiming aboud undefined symbols of iconv.
Any ideas ?
March 31st, 2008 at 2:45 am
Great Article.
One question. Where is the proper place to install pear??
go-pear wants to install in the current user's directory by default, but in your example, it appears that you installed to /usr/share/pear.
Any advice would be greatly appreciated.
April 1st, 2008 at 4:02 pm
Thank you for hints - it saved me a lot of nerves.
April 16th, 2008 at 12:50 pm
@Adam: http://www.google.co.nz/search?q=mamp or http://www.google.co.nz/search?q=xammp
April 27th, 2008 at 6:17 am
works like a charm! thank you so much, excellent post, saved me weeks of frustration..
April 29th, 2008 at 1:57 pm
Thanks so much for this post. The others didn't cover the full process or explain things properly. This made all the difference!
Thanks
April 29th, 2008 at 4:05 pm
How great it is to have things explained so well
May 1st, 2008 at 6:49 am
I've got Leopard on my G5 and I'm trying to get php with oracle oci to work with apache2
I haven't a clue how to get this done.
Before I upgraded from 10.4, I had Oracle running with Apache1 with php5 with OCI and no problems. Ever since the upgrade to Leopard my website has been effectively down.
Any help would be greatly appreciated.
Regards,
dajon@comcast.net
May 4th, 2008 at 11:27 am
Looking for advice on how to compile php as and embedded library. I amusing this for configure
./configure --enable-embed --with-curl -enable-ftp --enable-zip --enable-sockets --enable-static --enable-soap --with-zlib --with-bz2 --enable-exif --enable-bcmath --enable-calendar
I keep getting this error after running make
ld: duplicate symbol _yytext in Zend/.libs/zend_ini_scanner.o and Zend/.libs/zend_language_scanner.o
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
I have no idea what this means
any ideas... thanks
Todd
May 4th, 2008 at 8:27 pm
Thanks so much for the virtual hosts setup!!
May 5th, 2008 at 3:00 pm
Hi, I am trying to enable php. I followed most of the instruction, but it shows me the whole php code just like any other text file in the browser. doesn't show anything else than purely those texts. I am using Leopard 10.5. Do you think, you can help ?
May 6th, 2008 at 10:36 am
how na i install the DG2 Extension???
May 6th, 2008 at 10:23 pm
@website design
you don't. not with out much hair pulling and gnashing of teeth. switch to an all-in-one or try Mac Ports (more advanced terminal use required)
May 7th, 2008 at 12:37 pm
How can I revert ?
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
May 7th, 2008 at 7:06 pm
Wow, cool man, big thanks! http://etfdqecxzxdhq.com