Apache PHP and Mysql on Leopard

1:13 am
Leopard, Tips, how-to

Leopard brings one big change to web developers working with Apache, PHP and Mysql on the Mac. Apache 2 comes with Leopard along with PHP 5.

Here is what to do to restore a test environment.

First, you need to enable PHP.

Apache’s .conf file moved from /private/etc/httpd/httpd.conf to /private/etc/apache2/httpd.conf

Open this file with your favorite text editor and uncomment the line:

# LoadModule php5_module libexec/apache2/libphp5.so

You don’t need to add the mime type for php, because it’s already done for you under leopard. The last line in the .conf file is:

Include /private/etc/apache2/other/*.conf

The ‘other’ directory contains a .conf file for php5. That takes care of the mime type and the index.php configuration for php sites.

If you develop multiple sites and you need virtual hosting functionality, scroll down to the end of the .conf file and uncomment the following:

# Include /private/etc/apache2/extra/httpd-vhosts.conf

That’s all the modification that I had to make to to the httpd.conf file.

Next, you’ll need to setup whatever virtual hosts you have in the virtual hosts file /private/etc/apache2/extra/httpd-vhosts.conf

For example, for each line that you set up in your hosts file like so:

beta-site-1.com 127.0.0.1

You need to make an entry in the httpd-vhosts.conf file like so:

<VirtualHost *:80>
   ServerName beta-site-1.com
   ServerAlias www.beta-site-1.com
   ServerAdmin webmaster@beta-site-1.com

   DocumentRoot "/Library/WebServer/beta-site-1"
   ScriptAlias /cgi-bin/ "/Library/WebServer/beta-site-1/cgi-bin"
   <Directory "/Library/WebServer/beta-site-1">
     Options FollowSymLinks MultiViews Includes
     AllowOverride All
     Order allow,deny
     Allow from all
   </Directory>
</VirtualHost>

One good thing is that the ‘upgrade’ install of Leopard does not mess with your hosts file, so whatever virtual domains you may have set up won’t be affected.

If you had Mysql installed previously, good news too, Leopard’s installer won’t touch it. I found mysqld running just like before the upgrade.

One thing changed with Leopard is the socket for Mysql. It moved to /private/tmp, so you may need to configure your php.ini file to point it to the new location.

To do so, open the file ‘/private/etc/php.ini‘, (if no such file exists, then make a copy of ‘/private/etc/php.ini.default‘ naming it ‘php.ini‘) and edit that.

You have two lines to modify:

mysql.default_socket =

becomes:

mysql.default_socket = /private/tmp/mysql.sock

and mysqli.default_socket =

becomes:

mysqli.default_socket = /private/tmp/mysql.sock

of course, from the sharing pref pane, stop the server and restart it and voila!

90 Responses

  1. Simon Says:

    genius! :-) Thank you!

  2. Herve Says:

    Hello,

    I did upgrade to Leopard. I updated the httpd.conf and httpd-vhosts.conf files (in the apache2 directory). When I start the web server and try to access on eof the virtual host I get a message:Forbidden

    You don’t have permission to access / on this server.

    and int he console I can see the following message:(org.apache.htpd) Unknown key: SHAuthorizationRight

    I didn’t find anything on the web this error.
    The httpd.conf file has root for owner and wheel for group (sounds good).

    Do you have any idea?
    Thanks for your help
    Regards
    Herve

  3. Lazeez Says:

    if the server is responding, then the problem is not with the configuration files. Are you accessing a specific file on one of the virtual hosts or accessing a directory (the URL ends with a /)?

    If you can access a specific file, but can’t access a directory, then your default file name is not configured properly. It’s the index.html or index.php in apache .conf file.

    If you can’t access any file on the server, it’s a simple matter of permissions on the folder containing the files for the site. Check the ownership and the permissions on the site’s folder.

    Apache runs under user www and group www, so your site’s folder show be owned by user www and group www or the permission needs to be 0777.

  4. Leevi Graham Says:

    Excellent writeup!

    Super easy to upgrade but it would have been great if Leopard included Netinfo

    The hosts file is just as easy tho.

  5. Leevi Graham Says:

    Dugg!!! -> http://digg.com/apple/Easy_virtual_host_setup_in_Apache2_on_Leopard

  6. Isaac Rivera Says:

    Great post! I got apache + php running and working, but this is a new computer and I need to add mysql to the mix. How do I instal it and get it to play nice with PHP?

  7. Lazeez Says:

    To install mysql, you need to download it from mysql’s site:

    http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

    Select the version that suits your Mac, (powerPC or Intel). It says Mac OS X 10.4, but it will work on leopard.

    The .dmg file will contain 2 .pkg files, install both of them and restart your mac.

    After it restarts, open the terminal and type the following:

    /usr/local/mysql/bin/mysqladmin -u root password ’somepassword’

    where ’somepassword’ is the password you want for the root user of Mysql.

    That’s all there is to it.

  8. Isaac Rivera Says:

    Thanks Lazeez.

  9. Daniel Says:

    Thank you a lot, it has really helped. Now it all works perfectly. :D

  10. Jim Says:

    I have a similar issue. My previous installation of Apache2 no longer starts up on booting, and when I manually boot it, it loads Apple’s Apache2 instead of mine. I know I have to do some editing to get mine to run, but what and how? Thanks for any help.

  11. Lazeez Says:

    If there is a good reason for your not to use the system provided apache, and you absolutely must use the previous installation you have, then you need to point the startup item for the system to your own installation.

    You need to edit the file:

    /System/Library/LaunchDaemons/org.apache.httpd.plist

    and replace the string:

    /usr/sbin/httpd

    to point to your own installation of apache.

    Be careful, any mistakes and you could render your apache installation and the system one unusable.

  12. Joannou Ng Says:

    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/

  13. Brian Lokker Says:

    Could you explain this part of your write-up?

    “For example, for each line that you set up in your hosts file like so: beta-site-1.com 127.0.0.1″ …

    Which file is this? Is it the file that was modified using NetInfo Manager in Tiger? How do I find it now? I presume that if I want to add another virtual host, I have to get into this file.

    And then should I remove the virtual hosts that I had set up in /private/etc/httpd/httpd.conf and replace them with virtual host definitions in /private/etc/apache2/extra/httpd-vhosts.conf?

    I’ve tried following these directions but so far the server’s not being found, so clearly I am doing something wrong. Thanks in advance.

  14. Lazeez Says:

    the hosts file is located at:

    /etc/hosts

    I don’t think it was managed by netinfo. NetInfo had its own thing for domains.

    Usually, the default hosts file contains one entry:

    127.0.0.1 localhost

    For a development setup to work, each virtual host needs a pointer to tell your computer where to find the host.

    example:

    If you add to your ‘hosts’ file:

    127.0.0.1 testdomain.com

    and save the file.

    Then if you type ‘http://testdomain.com/’ in safari’s address field, then Safari will try to fetch the page from your own computer. So you configure the vhosts file for apache to respond to that request by doing the virtual host thing from the article.

    So in summary, the hosts file tells your browser on which computer to find a domain name (127.0.0.1 is your computer) and the vhosts file tells apache which folder on your computer corresponds to that domain.

  15. Jim Says:

    Thank you Lazeez. Those instructions are what I had to do before but have forgotten. You remind me though, that I can now use the built-in version. Previously I had my own Apache2 and used it instead of the then older version of Apache that came with Tiger. I assume all I’d need to do is move my pages along with the httpd.conf file, right? Thanks again.

  16. Lazeez Says:

    You don’t need to move your pages, you just need to configure Apple’s apache2 to point to your folder properly.

  17. John Says:

    Lazeez,

    Thanks for the info, it helped get me back up and going quick.

  18. kjusupov Says:

    Hi,

    Thanks for the info… Right now apache2 and php5 is up and running… Was quite easy to read/follow…

    I’ve got a small issue:
    When I check the status using phpinfo()

    I can see that mysql is supported, but nothing about PostgreSQL.

    - I’ve got PostgreSQL-8.1 running on the same MacBook

    - I’ve got uncommented the pgsql related lines in /private/etc/php.ini

    - stop/ start apache

    Still no good, no pgsql support…

  19. Lazeez Says:

    I’ve never used PostgreSQL, and I don’t have it on my systems. So I can’t help with that. Sorry.

  20. Area51 » Blog Archive » Apache, PHP i MySQL na Leopardu Says:

    [...] na Leopard je skroz rasturio moj Apache + PHP + MySQL setup. U ovom tekstu imate sve korake kako da vratite stvari u normalu. Ja sam imao tu nesreću da sam taj tekst našao [...]

  21. How I got MySQL and PHP running on Leopard [Bananaranha] Says:

    [...] Leopard from your Tiger installation you’ll perhaps have to do things differently. Here are some different instructions that might help [...]

  22. BleKo Says:

    Thank you for a very helpful article. Concerning the hosts file, mine looks a bit different:

    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting. Do not change this entry.
    ##
    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost

    I’m not exactly sure where or with what syntax to add my virtual hosts, because everything I’ve tried has resulted in either “Can’t find”– or “Can’t connect to server”. Any ideas? Thanks again.

  23. Lazeez Says:

    after the line that starts with fe80 simply add whatever host you want, like so:

    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost
    127.0.0.1 hostnametoadd.com

    of course, replace hostnametoadd.com with the host name you want.

  24. Kelvin Wee Says:

    I’m following the instruction, however, i am stuck at this step.

    2 issues,

    #1 – I couldn’t find this line in the httpd.conf

    # LoadModule php5_module libexec/apache2/libphp5.so

    #2 – i added it, and restart apache,
    it give me an error “can’t establish a connection to the server at localhost.”

  25. Lazeez Says:

    If you can’t find the line, that means you’re using a config file different from the one that ships with Leopard. Since you are, then I have no clue what that file looks like and options are set in it. The instructions above are for the default apache2 config file that ships in Leopard; not the one in the ‘original’ folder.

  26. Brian Lokker Says:

    I have the same hosts file as BleKo (comment 22), and I understand what you’re saying I should do with that file to set up virtual hosts. But I’m not getting that far: after following the instructions in the article, I still can’t get Apache to work. It doesn’t recognize localhost or anything else. Web Sharing says that my computer’s website is http://new-host.home/ but that’s not accessible either. And where does that name come from? Can I change it to localhost or 127.0.0.1 somehow, and would that help?

  27. Lazeez Says:

    What happens when you type http://localhost/ in your browser? If you can’t connect, that means one of two things 1) apache is not running or 2) your hosts file is not configured properly.

    My hosts files doesn’t contain the stuff that you guys have. Mine has:

    127.0.0.1 localhost
    127.0.0.1 testdomain1.com
    127.0.0.1 testdomain2.com
    127.0.0.1 testdomain3.com
    127.0.0.1 testdomain4.com

    If apache is misconfigured, then I have no idea how to fix it without seeing the whole httpd.conf file.

  28. Chris Says:

    I just upgraded to Leopard.
    I have the PHP and MySQL activated, and I hope, doing OK. I still have more testing to go on the MySQL install…

    However, I have the exact same problem mentioned above. The Apache server is running fine, but my user accounts (localhost/~user) are not resolving. I get “Forbidden” errors. This is despite the fact that they are set to chmod -R 0777, so it isn’t the file/directory permissions.

    I have individual user .conf files, like so:

    Options All
    AllowOverride All
    Order allow,deny
    Allow from all

    Options ExecCGI
    SetHandler cgi-script

    Any ideas?

  29. Lazeez Says:

    On my system, leopard didn’t create user directory files properly.

    Those should be located at:

    /etc/apache2/users/

    Mine had a Guest.conf file only.

    If your setup has a .conf file in that folder with your home folder name in it, then I don’t know why it wouldn’t work for you. Mine didn’t work until I created the file.

    For apache to serve your home site properly, you need to have a config file for it. The file should be:

    /etc/apache2/users/username.conf

    The file’s contents should be something like:

    <Directory “/Users/username/Sites/”>
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    of course, in both instances, the file name and the file contents, replace the ‘username’ bit with your own user name.

  30. mark Says:

    Everything works fine until I uncomment the virtual hosts line “#Include /private/etc/apache2/extra/httpd-vhosts.conf”

    Once I relaunch web sharing with this uncommented I get a cannot connect to server error.

    Also, I have a file “shortname”.conf in /etc/apache2/users/ as posted by Lazeez, but if I do a phpinfo() the document_root is still the default “/Library/WebServer/Documents”.

    I’ve even added: Include /private/etc/apache2/users/mark.conf to httpd.conf to make sure it’s getting the file, but it’s still not changing the document root.

    Thanks for any help, I’m new to using the built-in server and I’ve got a bunch of different sites so I really need virtual hosting.

  31. mark Says:

    As usual, found the solution moments after posting for help: http://alexking.org/blog/2007/11/01/apache-2-only-serves-first-virtual-host :)

  32. Joey Marchy Says:

    For those people struggling with getting the second virtual host site to work, like I have been, make sure both site declarations are inside the VirtualHost tags:

    ServerName beta-site-1.com
    DocumentRoot “/Library/WebServer/beta-site-1″

    ServerName beta-site-2.com
    DocumentRoot “/Library/WebServer/beta-site-2″

    I ended up having issues with the second site because I had two VirtualHost tag blocks.

  33. David Herren Says:

    >To install mysql, you need to download it from mysql’s site:

    >http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

    >Select the version that suits your Mac, (powerPC or Intel). It says Mac OS X 10.4, but it will work on leopard.

    OK, done.

    >The .dmg file will contain 2 .pkg files, install both of them and restart your mac.

    don’t need the startup item since I will use launchd. I have started mysql manually for now.

    >After it restarts, open the terminal and type the following:

    >/usr/local/mysql/bin/mysqladmin -u root password ’somepassword’

    where ’somepassword’ is the password you want for the root user of Mysql.

    Here’s where things fail. I have installed mysql many times in the past so assigning the root password is something I automatically, but on a clean install of Leopard, with the 4.1.22 mysql installer, the above appears to do nothing. when I attempt to log into mysql with (paths set):

    mysql -u root -p

    it tells me user root access id denied for ‘root’@'localhost’

    I’m sitting at the console as well… Any ideas.

  34. Lazeez Says:

    Restarting the Mac starts up mysqld with the proper parameters. Did you start it up with the same parameters as the startup item?

  35. David Herren Says:

    > Restarting the Mac starts up mysqld with the proper parameters. Did you start it up with the same parameters as the startup item?

    Not sure if that question is to me, but…

    Under Leopard the correct way to start any service is now to use launchd. I’ll be using this script:

    KeepAlive

    Label
    com.mysql.mysqld
    Program
    /usr/local/mysql/bin/mysqld_safe
    RunAtLoad

    UserName
    mysql
    WorkingDirectory
    /usr/local/mysql

    Until I have the root user configured, I’m reluctant to have it autostart…

    To start it manually, I just used:

    sudo ./bin/mysqld_safe &

  36. Johnny Says:

    I just don’t get it. I can’t find the httpd.conf file in my Leopard anywhere.

  37. David Says:

    > I just don’t get it. I can’t find the httpd.conf file in my Leopard anywhere.

    /etc/apache2/httpd.conf

  38. Lazeez Says:

    The script that the mysql startup script uses to start and stop the server is located at:

    /usr/local/mysql/support-files/mysql.server

    Try using that instead of mysqld_safe and see what happens.

  39. David Herren Says:

    > The script that the mysql startup script uses to start and stop the server is located at: /usr/local/mysql/support-files/mysql.server

    > Try using that instead of mysqld_safe and see what happens.

    I stopped mysql (remember that I’m using launchd to start it per the “norm” now under Leopard) and then started it using the script above. Still won’t let me access the database as root.

    At this point I’m once again back to a virtually clean Leopard install and a clean mysql install. I figured totally burning it again couldn’t hurt. On a clean mysql install one should be able to:

    mysql -u root

    without a password since the root password hasn’t been set, but I still get:

    www:support-files dherren$ mysql -u root
    ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)

    (note that I’ve also set my path variable so I don’t have to include the full path in every command–just in case anyone wonders)

    I’ve now got a call in to Apple support and I’m supposed to have a phone appointment with the server support group today at 11am EST to see if they can help me.

    I love Leopard, but the growing pains I’m experiencing are more like bruises…

  40. Neal Says:

    I was bashing my head against the desk wondering why my virtual sites were giving a ‘Forbidden – You don’t have permission to access / on this server’ message after upgrading to Leopard, despite the file/directory permissions on the web directories being unchanged.

    This happens if your virtual sites aren’t under /Library/WebServer/Documents.

    After actually realising Leopard had changed from using Apache1.3 to Apache2 I (eventually) looked at what differences there were in the httpd.conf files relating to directory access.

    (In what follows I’ll use square brackets to delimit apache directives in case angle brackets aren’t escaped when displaying as HTML).

    In Apache1.3 Apple’s httpd.conf has this:

    [Directory /]
    Options FollowSymLinks
    AllowOverride None
    [/Directory]

    [Directory "/Library/WebServer/Documents"]

    Order allow,deny
    Allow from all
    [/Directory]

    The [Directory /] block has an implicit Order Deny, Allow directive (i.e. the default) so that anything below the root of any site is, by default, accessible. (The [Directory "/Library/WebServer/Documents"] block’s directives are explicitly saying that anything within /Library/WebServer/Documents is accessible. This doesn’t change what is already allowed).

    However, in Apache2 Apple’s httpd.conf has this:

    [Directory /]
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    [/Directory]

    [Directory "/Library/WebServer/Documents"]

    Order allow,deny
    Allow from all
    [/Directory]

    The [Directory /] block now explicitly makes everything inaccessible below the root of any site by default. Now the [Directory "/Library/WebServer/Documents"] block’s directives are overriding this to grant access to everything under /Library/WebServer/Documents.

    That’s fine if your virtual sites are under /Library/WebServer/Documents but if they’re not you get ‘Forbidden – You don’t have permission to access / on this server’.

    The solution is simply to add an Allow from all directive for each virtual site’s DocumentRoot, e.g.

    [VirtualHost *:80]
    ServerName my.virtual.site
    DocumentRoot /some/other/path
    [/VirtualHost]

    Becomes:

    [VirtualHost *:80]
    ServerName my.virtual.site
    DocumentRoot /some/other/path
    [/VirtualHost]

    [Directory /some/other/path]
    Allow from all
    [/Directory]

    The Allow from all directive overrides the [Directory /] block’s Deny from all directive because it is processed afterwards and the last one processed wins.

  41. Gregg Says:

    I’ve uncommented the php line as instructed above, but when i load a page that uses php syntaxt (e.g. ), it does not parse it, it simple displays the text. any ideas?

  42. Lazeez Says:

    check to see if you have the php config file. In Leopard there should be a file:

    /private/etc/apache2/other/php5.conf

    its contents should be: (replace the square brackets with angled ones)

    [IfModule php5_module]
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    [IfModule dir_module]
    DirectoryIndex index.html index.php
    [/IfModule]
    [/IfModule]

    if the file is not present, then you need to create it and then make sure that the last line in httpd.conf file is:

    Include /private/etc/apache2/other/*.conf

    And restart apache.

  43. Andy Says:

    Thanks! made it easy for me!

  44. One Thousand Words » Blog Archive » PHP, MySQL and Leopard Says:

    [...] but it required doing 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 [...]

  45. screenmates Says:

    Hi,

    With virtual hosts setup, how can I use the URLs in a MVC framework where the urls look like:

    http://dev.local/module/controller/action/...

    where i need to use:

    http://dev.local/~user/module/controller/action/...

    That would replace the module argument with ~user and move other arguments one position down :(

    TIA

  46. Ricardo Says:

    If you’re still having 403/forbidden errors, and are using FileVault, this might help:

    http://ricardo.strangevistas.net/apache-unable-to-access-you-sites-on-os-x.html

  47. aman Says:

    thanx a lot …. i spent 2 hr figuring why my apache wasnt understand the php files until i found that leopard had changed the config files.

  48. Devin Columbus Says:

    I upgraded to Leopard and have just recently needed to do some local testing with php. The server seems to be running fine except the fact that I can’t redirect my pages…

    header(“Location: content.php”);
    exit;

    gives me an output error:

    Warning: Cannot modify header information – headers already sent by (output started at /Users/devincolumbus/Sites/widget_corp/create_subject.php:4) in /Users/devincolumbus/Sites/widget_corp/create_subject.php on line 18

    Do you know what might be causing this?

  49. Lazeez Says:

    Check that location. It’s probably an extra character somewhere. If you have edited the php files mentioned and by any chance converted them to UTF8, make sure that there is no BOM.

    What is on line 18 of ‘create_subject.php’?

  50. carotids Says:

    Thank you for your help. The fact that you are still answering questions here is very, very appreciated.

    I can access html files across my network. I can not access php files.

    Tail of my error_log doesn’t show any error when this occurs.

    http://10.0.1.123/~user/index.html works
    http://10.0.1.123/~user/index.php does not

    Cannot display the webpage error.

  51. Lazeez Says:

    That’s an odd one.

    Can you access the index.php file from the machine serving it?

    If PHP wasn’t working, you would have received the source code for the ‘index.php’ file. Getting an error message means that there was an error while processing the page and PHP produced garbage.

    try the following command in the Terminal (/Applications/Utilities/Terminal.app):

    curl -I “http://10.0.1.123/~user/index.php”

    and see what the output is.

    You can also try:

    curl -G “http://10.0.1.123/~user/index.php”

    That bypasses any interference from the browser and shows you exactly what the server is producing.

  52. carotids Says:

    Thanks.

    Somehow in trying to hack my way through this my mysql installation degenerated into a steaming pile of worthlessness. I am cleaning up the mess and starting over.

    My theory now is the mysql and php installation was working fine, and that the issue was the way wordpress was handling the php calls.

  53. John Wry Says:

    It blows me away that apple hasn’t got their stuff together. It’s all about Apache, mysql and this does not come working by default. Even installing mysql…there’s nothing about adding these two lines of code anywhere in the installs or on apple.com…ludicrous!

  54. TJA Says:

    Does anyone have a definitive, step-by-step solution to setting up a PHP, MySQL development environment in Dreamweaver CS3 on Leopard.

    I was so proud of myself for setting this up in Tiger… only to upgrade to Leopard and find out that I had to start all over.

    I second John Wry’s comment above. It is ABSURD that this is not easily turned on. Why not just have a System Pref area where you turn these things on and off with the click of a button? Or at least have an application that permits the easy activation and/or addition of various development tools.

    I am just starting as a PHP/MySQL developer, but it sure seems like I need to be an advanced developer just to get things set up! Not the kind of Catch 22 I would expect from Apple.

    Again, if any one can point me to a comprehensive, step-by-step tutorial-one that puts together many of the trials and errors that appear to have been revealed in the posts above– I would be most grateful.

  55. rad Says:

    Does anybody know help me how to start mysql in leopard???Ive tryed evrithing is mention here but no luck.Ive instoled mysql and add icon to system preferences and try to start up manulay by pressing button…but no luck….in terminal getting massage permition denied…???any help please :-)

  56. Lazeez Says:

    It could be permission problem with mysql’s ‘data’ directory.

    The default installation of mysql is at /usr/local/mysql

    there should be a folder/directory called ‘data’ inside mysql’s folder.

    Check its owner and group, they should be _mysql (note the underscore) and wheel.

    if they’re not, then you need to fix those permissions. You can do that with the terminal; just type:

    sudo chown -R _mysql:wheel /usr/local/mysql/data

    it will ask you for your admin password, just supply it and that should fix the problem. If it doesn’t, then I don’t know what the problem could be.

  57. rad Says:

    thanx for replaying back…unfortunatly your advice is not fixing problem :-( …if I go to data folder as u recomended that folder is lock for access have a one way sign on it (dont know how to access) and when i put that text code it to terminal nothing is happening…just asked for password …after typing password is just repeat text line name of mac and name of user…any other sugestion???

  58. Lazeez Says:

    nothing is supposed to ‘happen’ when you enter your password after that line. It should simply give you the prompt.

    But, after it, if you restart, mysqld should be running.

  59. rad Says:

    no i did restarted but no luck…BTW how do I know is running???it should show in system preference or sould i check in terminal?Cos in system preference is showing stopped

  60. Lazeez Says:

    Try ‘Activity Monitor’ in the /Applications/Utilities/ folder. Launch it and simply type ‘mysql’ without the quotes into the filter field (top right).

  61. rad Says:

    nothing is empty…is not on…:-(((

  62. rad Says:

    Ok thenx …
    Ive sold this problem for those who has same problem just type in terminal;

    sudo /usr/local/mysql/support-files/mysql.server start

    and that will start mysql right ON…:-))

    all the best to all

  63. peanut Says:

    Thanks! It very useful!

  64. Ben Thoma Says:

    Thanks so much! This really helps

  65. Anon7 Says:

    MAMP is worth a look – installs mySQL, PHP and Apache2 on a User account and does not touch your original OSX configuration.

  66. Tiffany Says:

    I’m new to programming. I’ve searched my mac up and down for these files but can’t seem to find them. I’m running Leopard on my Mac.

    Can you please explain where are these files located? Also, are these instructions for the client side or host side? As I’m interested on the client end.

    Thank you.

  67. Lazeez Says:

    You can’t use Spotlight to find the files mentioned in the article. They’re in the invisible folders of Mac OS X.

    You need to use the terminal for these kind of things. If you’re familiar with Terminal and its use, then the above should have been enough for you to get started.

    If you’re not familiar with the terminal and the intricacies of the Unix side of OS X, then you may be more comfortable with a package like ‘MAMP’.

    http://www.mamp.info/en/mamp.html

    This package allows you to install all the needed software easily and use your Mac as a PHP development platform.

  68. Will Says:

    Thanks again for this. Used it more than once as reference. Just had to use it again after a software update changed php.ini settings for the mysql.sock file. oh well.

  69. Sun Anon Says:

    Thanks, I had to do this in order to get phpmyadmin working properly.

  70. Christopher Skinner Says:

    Thanks so much. I just tried to use my local development setup for the first time since upgrading to leopard and it was broken. Your instruction were so clear and it only took a few minutes to fix. I’m very grateful!

  71. Anonymous Says:

    Last night, I tried installing mySql, ver. 10.5 (5.0.51a (x86), on my MacBook Pro (unsuccessfully).

    Prior to installing mySql, I enabled php as per the instructions on the top of the page. I then followed the advise about creating a php.ini copy and setting:

    mysql.default_socket = /private/tmp/mysql.sock
    mysqli.default_socket = /private/tmp/mysql.sock

    Next, I installed mySql, however, I cannot seem to start mySql or set the password (as per post no. 7) as follows:

    /usr/local/mysql/bin/mysqladmin -u root password

    Can anyone help a poor sap like me out? Also, what directory is mySql installed to?

    Thanks so much in advance!

    Cheers,
    Dipesh.

  72. Nomad Says:

    Hi Dipesh. Got a MBP too running OS X 10.5.2 and the same problem as well. Here’s the solution in four simple steps:

    1.- download this
    ftp://ftp.mysql.com/pub/mysql/download/gui-tools/MySQL.prefPane-leopardfix.zip
    and replace the PefPane.

    2.- Go to the Finder, press Command-Shift-G and type this:
    /usr/local/
    A window will open

    3.- Find and copy the MySQLCOM directory to Library/StartupItems/. If you get any error, simply copy the MySQLCOM folder to our desktop and then to the StartupItems folder. You will have to enter your administrator pasword to allow the MySQLCOM folder to be copied onto the StsrtupItems folder. Don’t worry, this is OK.

    4.- Restart your Mac and enjoy MySQL.

  73. Sam Says:

    Hello

    I just edited the conf file, but when i try a php test page with , but when I open it, i just see that code…

    help?

    Sam

  74. Kane Says:

    Hey i changed the files as you said, (.conf file and the file to create virtual hosts). But wondering now how do i set this up to dreamweaver so i can use that to edit my pages and just connect to my site?

    any help would be appreciated

    thanks in advance

  75. StephenT Says:

    Let me join in the chorus of THANK YOUs. I’ve been to so many places that say ‘just download this file and double-click and voila! you are running php & apache.’ but after lots of frustration, php and apache still were not talking. Your instructions were clear and simple and they work. For the first time, running the phpinfo() command actually returned a response. Many many thanks!!

  76. Donna Says:

    Adding my thanks, especially for the MySQL socket as I hadn’t seen that part elsewhere and was baffled!

    One hint if the virtual hosts aren’t working – in my old httpd.conf file I had just used * for the port instead of *:80. When I changed the port # in the entries it worked:

    [VirtualHost *:80]
    ServerName my.virtual.site
    DocumentRoot “/some/other/path”
    [/VirtualHost]

    Also originally I did not have the DocumentRoot value in double quotes but adding the quotes did not make things work any better.

  77. Anonymous Says:

    Brilliant, absolutely phenomenal. A Wizard with enough knowledge to make it a one shot for the transition to Leopard from Jaguar!
    Thanks, and cheers aplenty!

  78. siong1987 Says:

    I have problem making php up and running.

    I tried the command “curl -I “http://localhost/~macbookpro/info.php”

    I get this results:
    HTTP/1.1 200 OK
    Date: Sat, 28 Jun 2008 12:56:15 GMT
    Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7l DAV/2 PHP/5.2.5 Phusion_Passenger/2.0.1
    X-Powered-By: PHP/5.2.5
    Content-Type: text/html

    But, if i run “curl -G “http://localhost/~macbookpro/info.php”

    I get this:

    Parse error: syntax error, unexpected ‘?’ in /Users/macbookpro/Sites/info.php on line 1

    Anyone can help me? Thank you.

  79. Lazeez Says:

    Without seeing the source code for the ‘info.php’ file, we can’t help.

  80. Scott Says:

    Brilliant. Saved me hours. Thanks.

  81. SourceFusion » Safari vhost quirks and ‘access denied on /’ Says:

    [...] I came across a page that explains how to setup Apache, PHP and MySQL on Leopard and in the comments (#40), I found the answer to the [...]

  82. naz Says:

    YOU ARE A GENIUS!!!. Thank you so much.

  83. jas Yang Says:

    why are two lines the same?

    mysql.default_socket =

    becomes:

    mysql.default_socket = /private/tmp/mysql.sock

    and mysqli.default_socket =

    becomes:

    mysqli.default_socket = /private/tmp/mysql.sock

    of course, from the sharing pref pane, stop the server and restart it and voila!

  84. jas Yang Says:

    ; MySQL defaults.
    mysqli.default_socket =

    ; Default host for mysql_connect() (doesn’t apply in safe mode).
    mysqli.default_host =

    ; Default user for mysql_connect() (doesn’t apply in safe mode).
    mysqli.default_user =

    How do I configure it?

  85. LC Says:

    Your post lives on! I wracked my head for 2 days reading everything on this and finally found your post.

    I had set up the Virtual Host, and permissions were fine, but still had a forbidden problem until I nested the in the httpd-vhosts.conf

    Yeah – I’m virtually dancing – pun intended.

  86. tony tredway Says:

    running G4 powerbook leopard 10.5 6 client
    cannot get apache default page
    error cannot find server

    edited http.conf for php
    tried most of the above still cannot get default page to appear

  87. Joel Folkesson "noob apache guy" Says:

    I wonder.. like when i say //localhost bla bla. this apache thing pops up. and that made me wonder. like when I do //localhost~(username) all I have in the folder “sites” will pop up, and I wonder if I can change the //localhost “start up thingy” when it just sais Apache is Fully installed on this computer. blabla. U probably Don’t understand but I hope someone would Answer me As soon as possible, im really curious :P

  88. jessica Says:

    THANK YOU for this post! I was stuck on the socket thing for a while and wouldn’t have figured it out if I didn’t find this.

  89. Jens Larsen Says:

    I’m sort of a newbie with php in general and on Leopard (10.5.7) in particular. Only got my Macbook Pro last month. If not for this post I would have still have been flailing away at windmills.

    There seems to be a difference from the version of Leopard/php5 that you describe to what I have. The reference to the php5.conf file in /private/etc/apache2/other/ was nowhere to be found in my httpd.conf file. I had to add the include at the bottom of the includes myself. I then restarted apache, flushed the Safari buffer/cache, and finally I got to work instead of just showing the source code.

    My sincere thanks!

  90. tidbeck Says:

    Thank you!

    The php mysql.default_sock setting saved my day!

Leave a Comment




Your comment


You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.