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.
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.
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.
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?
Jeff Moore’s Blog: Working with PHP 5 in Mac OS X 10.5
Yep, Tiger could use netinfo, but apparently Leopard has deprecated netinfo and the netinfo manager is no longer installed.
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?
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
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.
[...] his latest post, Jeff Moore talks about a much needed upgrade to a popular operation system (the Leopard version of [...]
[...] [UPDATE] The most comprehensive solution to date is here. [...]
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.
I just saw that DB is suspended. I will install the package for my older projects… Thanks.
[...] zu MySQL bin ich im Übrigen auf diesen, sehr ausführlichen und hilfreichen Artikel gestossen: Working with PHP 5 in Mac OS X 10.5 Verwandte Artikel:Leopard in der PostMySQL und Mac OS 10.4 Windows CE der Sieger? Bitte bringt [...]
Your article is really good. Except for two small problems.
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.
Looking forward to your directions for compiling, I’ve not had any luck due to problems with the mysql bindings.
[...] is a great article on this here. No Comments, Comment or [...]
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.
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.
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?
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!
[...] I had to re-install MySQL. I used the 10.4 package, and the startup item appears to work. I used this article, which deals mostly with setting up PHP in Leopard, to edit my “my.cnf” file so that PHP could find [...]
[...] found a helpful post and was able to get everything up and running again in about an hour. if your stuck configuring a webserver on leopard mac OS 10.5 check out this link – http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ [...]
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!
@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.
[...] blog suggested go-pear.php as an alternative way to install PEAR on the Mac and it does work. So with no [...]
[...] mais il semble bien que Léopard soit livré avec PHP5. Sous réserve de quelques manipulations (Working with PHP 5 in Mac OS X 10.5 – en anglais), il est possible d’avoir une magnifique installation (incluant PHP5, PEAR et [...]
[...] Working with PHP 5 in Mac OS X 10.5 – Jeff Moore (0 visite) [...]
[...] Working with PHP 5 in Mac OS X 10.5 – Jeff Moore (0 visite) [...]
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP php 5 leopardon (via vbali) (tags: PHP Leopard osx Mac Apache howto server) [...]
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/
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.
[...] leopard és web development This entry was written by ioros and posted on 2007. November 2. at 12:24 pm and filed under Url. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Comments are closed, but you can leave a trackback: Trackback URL. [...]
[...] If you just can’t wait to upgrade, then I strongly suggest heading over to this excellent step-by-step guide to installing LAMP on Leopard. Follow the steps precisely, and fill your mug of patience to the [...]
[...] auf dem neuen Mac OX X Leopard PHP installieren möchte, finden eine gute Anleitung im Blog PHP Programming, Web Development, PHP Advocacy and PHP Best Practices. Bookmark to: (No Ratings Yet) Loading [...]
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.
[...] It was rather worrisome (and my Internet connection was acting up at the time), but then I found Working with PHP 5 in Mac OS X 10.5 (Leopard) and it solved that problem. Phew. [...]
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.
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.
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…
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…
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!
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.
[...] quote. Having spent the entire day cursing the ground Jobs walks on, I finally stumble across the greatest blog post I’ve ever read. And I quote: “…the default configuration in Leopard, unlike in Tiger, does not allow [...]
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!
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.
[...] Apache2 and PHP5, and enabling it is as simple as uncommenting a line. Check out this guide for a full tour of using Apache2 with PHP5 and MySQL on the latest release from [...]
Thanks! this post was a lifesaver
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional 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 en (tags: Apple Mac php development howto web webdesign server security sharing) [...]
[...] al punto que iba es que me encontre con un blog (Professional PHP) que da las intrucciones sobre como habilitar el PHP5 que ya trae el Mac OS X 10.5 (Leopard) en el [...]
[...] die Leopard Version von Mac OSX hat man ganz schöne probleme mit dem Apache , Php und Mysql. Auf dieser Seite findet man die Lösung [...]
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.
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…
…
[...] a more thorough walkthrough take a look at this. November 7, 2007 | Filed Under OSX, [...]
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) [...]
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
[...] dig som är intresserad av att jobba med PHP5 i Mac OS X 10.5 Leopard kan denna guide vara [...]
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.
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!
@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.
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.
[...] PHP5 beim Leo: http://www.procata.com/ [...]
[...] try to use the existing Mac OS X install of PHP as it is now running on PHP5 in Leopard. I used a guide I found via kevin rose’s blog as my instruction on how to get the Mac OS X PHP install functioning. The process basically comes [...]
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.
[...] After I upgraded to Leopard from 10.4.x, my PHP processes stopped working. Â The new OS overwrote some configuration files. Â Check out this post on how to get things working again. [...]
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
@ 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
[...] Mac OS 10.5 is out, there are a few changes to PHP, MySQL, and Apache. Here is a good, basic, article that outlines those changes/setup [...]
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.
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)
Great and
veryuseful article! Thank you!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.
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.
Thanks a lot buddy. Worked very well. Just perfect.
[...] more thorough guide is here if you run into different issues or need more help. I should note that I disagree with [...]
[...] Link [...]
[...] some workaround to get it working properly. I found some good help at My Macinations and again at Professional PHP.To make a long story short, because this is mostly a reminder for myself, the key resources for [...]
You can install a completely different set of LAMP on OS X using Mac Ports.
Thanks a bunch for your time on this – helped my a great deal, everything fell into place as described. Muchos!
[...] For more info on setting up a PHP website on an OS X box try Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP [...]
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
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
[...] add the modules for pdo_mysql and the pear libraries… so i’ll refer you to this post or this one before you go reinstalling apache and rebuilding php5 from source.. and getting lost in Leopards [...]
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP: “” [...]
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?
how about viewing the error_log on local…. anybody who has an idea?
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!
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.
Forget my above post. I just didn’t restart the web sharing after uncommenting the line in the apache config file.
Cheers,
Michael.
Stifo gets the platinum star for Post 84…it was the only thing that worked for me!
Thanks, dude!
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.
Thanks for the instructions, it really helps me
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
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
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) (also has information on setting up PEAR) [...]
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.
[...] some searching on how to do this (remember, I have never used a Mac before) and came across this fantastic tutorial. I was up and running in minutes. Everything worked perfectly except for one thing. The default PHP [...]
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
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.
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).
@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.
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP How to enable and work with PHP5 in Mac OS X 10.5 (tags: php development programming mac apache) « links for 2008-03-18 [...]
[...] Working with PHP 5 in Mac OS X 10.5Â – a most complete guide [...]
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 ?
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.
Thank you for hints – it saved me a lot of nerves.
@Adam: http://www.google.co.nz/search?q=mamp or http://www.google.co.nz/search?q=xammp
works like a charm! thank you so much, excellent post, saved me weeks of frustration..
[...] Link http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ [...]
Thanks so much for this post. The others didn’t cover the full process or explain things properly. This made all the difference!
Thanks
How great it is to have things explained so well
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
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
Thanks so much for the virtual hosts setup!!
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 ?
how na i install the DG2 Extension???
@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)
How can I revert ?
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
Hi,
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.
I’ve tried building a soap extension for the stock php in leopard, without success. I really cannot figure out why it should be all that difficult. My struggles are documented here:
http://www.entropy.ch/phpbb2/viewtopic.php?t=2956
http://discussions.apple.com/thread.jspa?messageID=7046696�
Has anyone gotten any further?
From http://netevil.org/blog/2007/11/php-objective-c-bridge:
[quote]note: you’ll need to build your own PHP on Leopard, the one Apple ships has had its exports stripped, so you can’t run the extension–it’ll build, but not run[/quote]
Maybe that’s the reason why we’re unable to build extension for the stock php in leopard?
Thanks for the set-up!!!!!!!!!!!!
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP sudo php -q go-pear.php (tags: php reference) [...]
Thank you guy
There are actually a few different ones out there. I have been giving this software a go and see how it pans out.
You have a great site and i return to it ever now and then as i find the time.
Hello, thanks for this post, I moved to Mac few days ago, so it was really helpful and saved me lots of time.
I’d like to add something to the mysql.sock problem. Instead of making my.cnf and etc. it’s enough to make /var/mysql/ directory and put a symlink there.
So:
sudo mkdir /var/mysql
cd /var/mysql
ln -s /tmp/mysql.sock mysql.sock
That’s it.
Thanks again for the post.
Even after moving the username.conf file into the apache2/users directory I get a 403 Forbidden error when trying to access http://localhost/~username.
Works fine when loading from WebServer/Documents so Apache and PHP are both up and running.
I’ve even tried playing with permissions in my site directory to no avail. I’d appreciate the help!
[...] After asking for help from Colin, who gave me a head start and some google’ing, I found a solution. [...]
I’ve spent considerable time on blogs, support pages, Apple, PHP, etc. and haven’t found any other experiences like this (environment details at bottom). I’ve had current, stable versions of PHP running on many versions of OS X but it’s a stumper this time. Problem: basics of PHP work – variable assignments, include files, etc. – but errors ALWAYS occur with ANY function; usually “Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING”. As I say this is the result of any function, simple or otherwise. Laughingly, the function that does work is “function_exists(’somefunction’)”. I surmise it may be permissions or something similar but I can’t seem to get a solid lead. Any pointers would be welcome.
OS X 10.5.3, PHP 5.2.5, Apache 2, php.ini file in /etc has include_path = “.:/usr/local/php5/include”, /etc/apache2/httpd.conf configured correctly.
Has anyone had trouble finding #LoadModule php5_module libexec/apache2/libphp5.so in /private/etc/apache2/httpd.conf.
I find the file, but that line doesnt seem to exist.
Thanks
Thanks so much for this post.It was really helpful
Luca
hi,
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.
thanks.
[...] Configure Apache to run PHP on your Mac (these instructions are for Leopard, but similar ones are out there for Tiger) [...]
[...] Working with PHP and Leopard [...]
Hi and thanks this is a good tutorial.
I was wondering if you or anyone knows how or if it is possible to upgrade the bundled versions of both Php and Apache that ships with Leopard. How deep are they bundled? (meaning: do they just come as preinstalled or are they really deep and mixed into the system (or something like that)).?
It is indeed a very comprehensive tutorial for PHP on mac. Lot of help on PHP with windows is available but quality resources like this for other operating systems rare.
[...] procata.com: This was the best resource I found and well worth checking out as it shows you how to install the PEAR extension. Has a some great tips that I didn’t cover here. [...]
I created Virtual Hosting as directed above but i cannot the sub directories i created. Like i entered ‘r’ as a new site in the file now where do i find this directory. I searched almost everywhere.
I cannot find the /etc/apache2/httpd.conf file? I typed it into spotlight. How do we open that?
Thanks all!
Thank you very much, this is just awesome and was of great help.
[...] Working with PHP 5 in Mac OS X 10.5 Leopard – Professional PHP. Post a comment — Trackback URI RSS 2.0 feed for these comments This entry (permalink) was posted on Friday, August 15, 2008, at 4:58 pm by erik. Filed in tutorial. [...]
Very good tutorial, really of good help! I found it by googling. Thanks!
I made a widget to start and stop the MySQL server for Loepard; in this way I don’t have to leave an application open during work, but only a widget.
If interested, you can find it at http://www.inerziasoft.eu/en/soft/mysql.html.
[...] ships with MAMP, so installation is a breeze. If you’re not MAMP, then you’ll have to configure PHP to run on your Mac, which is a much more involved process. Still, phpMyAdmin is a tried and tested solution for [...]
[...] of the first challenges was to figure out how to get it working on my Mac. After following this tutorial on how to enable the version of PHP that comes with OS X Leopard, the Apache web server, and [...]
I have leopard Mac OS X VERSION 10.5.4.
I installed php Apache. SQL. I also enabled PHP. BUT WHEN ENTERING in Terminal sudo cp *.conf /private/etc/Apache2/users or cd /private/etc/httpd/users. I KEEP GETTING THE MESSAGE BELOW
cp: *.conf: No such file or directory.
I have httpd.CONF in the HD PRIVATE.
What do you think it canbe wrong. I spend 2 days trying to fix this but i get the same message.No such file or directory.
Hi,
I run Leopard and have followed the tutorial hoping to be able to start my Apache server, unfortunately it still doesn’t work. When I type http://localhost/ into my browser I get the error message
Safari can’t find the server.
Safari can’t open the page “http://localhost/” because it can’t find the server “localhost”.
I’ve been trying to start this Apache server for hours now, do you have any ideas for helping me out?
Thank you,
Mihai
[...] need to enable root user, for see the official help here.If you want your own version of PHP, see reference here. I got version 5.2.6 from that came with Leopard.Leopard has PHP built-in so I just need to [...]
Thanks for all this instruction.
A simpler way to make php to work with the default installation of MySQL is to change the default setting in php for the mysql.sock file…
I added
php_value mysql.default_socket /tmp/mysql.sock
to the /private/etc/apache2/other/php5.conf
file (in between the tags of course)
[...] layer, not those database specific mysql_* functions. So I followed the instructions at HiveLogic and [...]
Excellent tutorial. I’m work the day shift as a software engineer and this was perfect for me. No cruft, no BS, I got up and running fast. Nice job.
[...] order to run cakePHP we need to activate PHP. This guide basically gives you all the info you need to succeed with this task. In this article you will also [...]
You. Are. Amazing.
VERY well written tutorial, it worked perfectly first time around!!
Cheers!
Very good Tutorial – perfect for me as Mac-newbie!
The only problem i ran in was the configuration of name based hosts with an Apache “forbidden error”.
As I added after NameVirtualHost *:80
DocumentRoot /Library/WebServer/Documents
ServerName localhost
now verything is doing fine with virtual hosts.
Thank You!
Outstanding tutorial, so many thanks to you for taking the time to publish this.
method described for installing pear no longer works.
curl “http://cvs.php.net/viewvc.cgi/pearweb/public_html/go-pear?revision=1.118&view=co” | php
however, I’m running into permission problems with the default usr/local/ directory, to permit the pear installation; the installer can’t create the sub-directories.
Hi,
I am as close to a php novice as there is.
I do not know very much about php at all. I am a pretty good html writer and basic actionscript but thats about the extent of my skills. I am trying to learn php.
I tried to setup my leopard mac with a php tut on vtc.com. I tried to install one of the php packages of php.net but then at the end of install my mac said install failed. Then I tried to install a different one that said it worked. But the commands I type in terminal to try and follow the tutorial say the directory isnt set up and so forth. I think I need to reset everything and start over. Is there a way I can reset the files I made and restore my php and mysql settings to default?
Thanks!
Paul
[...] Apache2. If you’ve enabled OS X’s built-in copy of Apache2, then just go to System Preferenes, select “Sharing”, UNcheck the “web [...]
[...] OS X PHP/PEAR guide Share and Enjoy: [...]
Thank you for this very helpful article!
[...] via Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP. [...]
A little help, please. I’m stuck at “Enabling a Personal Website”, working with Leopard 10.5.6.
Before creating my “bruceporter.conf” file, the URL for “Your computer’s website:” works, and I can serve up info.php.
I create “bruceporter.conf”, with the virtual hosting directives, but cannot get the “Your personal website:” URL to work, or “http://mysite/” (I get the “Forbidden” message).
I have index.php in the bruceporter/mysite directory. I have /etc/hosts set with an alias. I’ve rebooted, checked spellings, and gone back to square one myriad times.
What I am missing?
PHP is a great programming language… and the Mac is a superb programming platform.. While most people may somewhat know the former, there are a large number of programmers who still believe that Mac is for graphic designers…
However, having said that, while the Mac has the great console of unixes and linuxes, and a very elegant UI desktop system, their WYSIWYG development tools are very limited. I would say that where Windows user has Dreamweaver and Frontpage, the Mac has almost nothing ( not any good ones as of Feb 2009 )… and now frontpage is yet evolving again into expression web…
Use Mac for c/c++ unix/linux development, or for Mac based UI stuff.. and console based scripting..If u need to do websites.. I firmly believe that Windows ( for all its viruses, bugs and evil quirks ) still has the best visual tools for development.
How do you load a module on a Mac? I’ve never done so and having some trouble. I’m pretty much trying to load the calendar.so. Any tips?
http://au2.php.net/manual/en/calendar.setup.php
Thanks!
[...] There is a very simple toggle for running php4 or running php5 built into Mamp. I am also using the native php5 build that ships with Mac OSX 10.5. Published by gregory on February 23, 2009 in Projects and Servers [...]
[...] Just not yet…I’m going to bed. But so far, this has been a helpful tutorial. [...]
[...] upgrade auf die Leopard Version von Mac OSX hat man probleme mit dem Apache , Php und Mysql. Auf dieser Seite findet man die Lösung dazu. Tags » Trackback: Trackback-URL | Feed zum [...]
I’ve been using Lynda.com for mysql & php. I’ve been stuck on why my php won’t show up. You’re a life saver. Thank you thank you thank you!
I am a recent mac convert, trying to setup my testing environment on my brand new iMac. Your article has been very helpful. I am still having one small problem I’m hoping you can help me with. My virutal hosts are all set up and working – except the php code doesn’t run when the file has an .html extension. I have added “AddType x-mapp-php5 .html .htm” to my .htaccess file. I also tried adding
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
to httpd.conf.
neither of these helped (after retarting the server).
Any ideas you could throw my way would be greatly appreciated…
Thanks,
Carol
[...] file” without first telling you what file it’s on about, or where it is) but i found a much more helpful page… which also suggested installing ‘Text Wrangler‘, a fully functional (and free i [...]
Hi, thanks to this web page I found out the solution to a problem that was driving me crazy! Re adding a username.conf file to my /etc/apache2/users/username.conf
Perfect! Cheers once again.. Im book marking this page!
Thanks dude, that was helpful.
P.S. By the way don’t you think it is unsecure to allow people insert tags into comments on the website?
[...] View original post here: Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP [...]
[...] da questo articolo, spero di riuscire a spiegare al mondo come configurare e installare un server web su Mac Os X, [...]
I too would love to see instructions for recompiling PHP on Leopard.
I want to use the ‘mailparse’ functions for an email project. It happens that the last recipe in O’Reilly’s “PHP Cookbook” (2nd ed) is about installing PECL extensions, and it uses ‘mailparse’ as the example. The recipe implies that all one has to do is run the ‘pecl install mailparse’ command and then add ‘extension=mailparse.so’ to the php.ini file. I did this much and restarted apache, but I get an ‘undefined function’ error when I try to invoke any of the functions.
The PECL documentation says I need to recompile PHP to enable mailparse.
Does this mean the PHP Cookbook instructions are incomplete? If not, where should I be checking for an error? If so and I need to recompile, has anyone done this before without too much hassle?
[...] ships with MAMP, so installation is a breeze. If you’re not MAMP, then you’ll have to configure PHP to run on your Mac, which is a much more involved process. Still, phpMyAdmin is a tried and tested solution for [...]
For all those on about recompiling php for mac may have a sweeter answer in the form of someones already done it for you.
http://www.entropy.ch/software/macosx/php/
Read, Install, Enjoy!!!
great one.
but one thing i got this error “Cannot load mcrypt extension. Please check your PHP configuration.” while loading phpmyadmin.
any solution??? help !!!
[...] After asking for help from Colin, who gave me a head start and some google’ing, I found a solution. [...]
Cannot load mcrypt extension. Please check your PHP configuration.”
I’ve been using Lynda.com for mysql & php. I’ve been stuck on why my php won’t show up. You’re a life saver. Thank you
Thank you very much.
I’m still new to website publishing and have found this very helpful. The one problem I am having is that I want Apache2 and PHP to work with a ‘non standard’ directory: /Users/$USERNAME/Documents/Web_Development with subfolders being treated as virtual hosts. Applying the above method to this path and not the ~/Sites path does not appear to work – or rather I can’t figure out how to make it work…
Any pointers gratefully received
//simon
These instructions are great! Really helped me to get things sorted out on my local machine. Thank you, thank you, thank you.
Hey all. I’m having problems with this, again. Initially everything was fine and I made all the changes and everything was running. But, I recently had to restore my system because of a bad update and can no longer establish a connection to the local testing server despite everything being in place (at least as far as I can tell). Can someone please help reestablish this connection??
[...] Bring the mysql.sock to PHP [...]
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) (also has information on setting up PEAR) [...]
[...] great article before for instructions on enabling the built-in PHP5 functionality of 10.5 Leopard (this article is not so bad either), but with 10.6 Snow Leopard install I did today, I found that I was getting [...]
Your instructions were so simple and straightforward that I was up all night wondering why they didn’t work for me. I think the answer is that ’something’ that should be pointing to the php5.conf file isn’t, so that there was no appropriate MIME type in httpd.conf to handle PHP, so I just ended up with the text of info.php being displayed. I manually updated the MIME types (and the directory index to accept index.php), and that fixed it.
This is with factory-installed Snow Leopard, updated to 10.6.1 before I started configuring Apache, so maybe there’s been a little change. (I guess it’s also possible that, since php5.conf calls for DirectoryIndex to contain index.html and index.php, that my having already expanded the list of directory index files–index.htm, default.htm, etc.–kept it from doing what it’s supposed to.)
At any rate, thank you for a good, straightforward article, without which I would have been unable to get myself into such a perplexed state, much less work my way through it!
[...] PHP, with phpicalendar [...]
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) [...]
I am having problems with php5, personally I prefer php4 so I never enable php 5 in my website or blog.
It’s great to have a local testing environment back – thanks.
[...] It was rather worrisome (and my Internet connection was acting up at the time), but then I found Working with PHP 5 in Mac OS X 10.5 (Leopard) and it solved that problem. Phew. [...]
Cannot load mcrypt extension. Please check your PHP configuration.” +1!!!
______________________________________________________________________
| |
| Cannot load mcrypt extension. Please check your PHP configuration.” | +1!!!
| |
———————————————————————–
How to install mcrypt?
I am stilling getting “You don’t have permission to access /~michael/ on this server” When i try to acces “http://localsite/~michael/” . I changed my /etc/apache2/michael.conf file to “AllowOverride All”. Any help would be great.
[...] http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ (helpful to get PHP running properly on 10.6) [...]
[...] It ships with MAMP, so installation is a breeze. If you’re not MAMP, then you’ll have to configure PHP to run on your Mac, which is a much more involved process. Still, phpMyAdmin is a tried and tested solution for [...]
[...] It ships with MAMP, so installation is a breeze. If you’re not MAMP, then you’ll have to configure PHP to run on your Mac, which is a much more involved process. Still, phpMyAdmin is a tried and tested solution for [...]
I once had a VPN problem before when accessing back to my intranet at home from hotel or airport so I changed my intranet IP address range from 192.168.0.x to 92.68.0.x. Accessing the web server running on my Leopard laptop from the same laptop was just fine as expected, but when accessing the same server from other computers on the same intranet (within 92.68.0.x range), the browser always times out. It looks like the browser was trying to retrieve the page from the internet but not the intranet.
Btw, I also had WinXP running from VMWare Fusion and the Network Adaptor Setting in Fusion was ‘NAT’, it was fine accessing to the server at 92.68.0.x from Internet Explorer from the Fusion. Should I change the intranet IP range back to 192.168.0.x? The VPN problem I had at Dallas Airport a year ago was that the coffee shop offered free internet and my laptop was given an IP address 192.168.0.xxx which happened to be the same as my intranet. My VPN was fooled into thinking that the VPN connection was already made.
IMHO It’s more easy to just configure mysql.sock to /tmp/mysql.sock inside php.ini.
Just set this values:
pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
[...] Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP (tags: apache lamp php php5 osx macosx mac pear mysql install) [...]
[...] Continue reading/Seguir leyendo This entry was posted in Programming and tagged php, web. Bookmark the permalink. ← ¡Hola mundo! php | tek 2008 → [...]
Nice post man Thanks
Hi, thanks much!
Can anybody explain why HTTP Error 400 generate sometime with comment having rough text (like :/\#%*.weq qeq). This generate only on my web server not on
localhost
[...] http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ September 7, 2010 7:44 am Anonymous Thank you so much for the awesome answer. Renaming the [...]
I’ve gotten valuable freelance jobs that teetered on replying to an email less than an hour after getting the first. I’ve come up with ingenious ideas when a friend burst into my room to strike up a random conversation.
If serializing is prioritized over habits then won’t serialized project approach cause you to constantly work on the next group project? As project time is impossible to calculate you will eventually have to breach particular habit times.
Great sit, I really enjoyed this post. Keep up the good work!
Good overall article, but I have to admit that I got quite confused with how to set this up and ran into some trouble along the way. I found this site that didn’t go into as much detail, but it did help me get setup. Hopefully it will help someone else out, too: http://www.sirtechalot.com/how-to-be-a-web-developer/how-to-setup-apache-and-php-5-on-mac-osx/
[...] are many articles on the web related to enabling Apache and php on OSX, but I found them to be overly complicated, or scattered, [...]
I have read many other walk throughs on how to use my mac’s apache server with php. I was unsuccessful UNTIL NOW… You were very detailed and explained how to perform this task.
IT WORKS!!!
Thank You!
I saw the tutorial about installing in php at lynda.com but they got the steps wrong unlike you, thanks for sharing this, it worked for me following your steps.
I was having huge problems setting up virtual hosts on my Mac in my Sites directory and went through countless directions. I finally found your page and it was the only one that worked.
Thank you!
I’ll be a regular reader of this blog
While I in the beginning commented at http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105 I clicked on the – “notify me”- checkbox and now each and every time a remark is included on Working with PHP 5 in Mac OS X 10.5 (Leopard) – Professional PHP web site, I get a number of electronic mails with the related feedback. Perhaps there is in whatever way it’s possible to remove myself through that service? Thanks!
[...] Another article: Working with PHP 5 in Mac OS X 10.5 [...]
[...] It ships with MAMP, so installation is a breeze. If you’re not MAMP, then you’ll have to configure PHP to run on your Mac, which is a much more involved process. Still, phpMyAdmin is a tried and tested solution for [...]
[...] changes in httpd.conf/php.ini files. You can probably find tons of tutorials on that topic (try this one for example) so not gonna waste my time on explaining how to do [...]
[...] procata.com: This was the best resource I found and well worth checking out as it shows you how to install the PEAR extension. Has some great tips that I didn’t cover here. [...]
thanks for this….nice to read a plain english version of how to run PHP on OSX…and it works!
[...] are many articles on the web related to enabling Apache and php on OSX, but I found them to be overly complicated, or scattered, [...]
[...] http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/ [...]