Mac OS X Server 10.4.4: Improvements to Apache/PHP/MySQL interaction

  • Last Modified: September 09, 2008
  • Article: HT3077
  • Old Article: 302977

Summary

Mac OS X Server 10.4.4 resolves two issues with the default interaction between the versions of PHP and MySQL that are pre-installed on Mac OS X Server:

  • PHP's MySQL client libraries are updated so that it recognizes the more secure authentication mechanism available in recent versions of MySQL. Therefore it's no longer necessary to start MySQL with the --old-passwords option or force MySQL passwords to the old format, though old format passwords will still be recognized.
  • The default socket location for PHP and MySQL is now the same (/var/mysql/mysql.sock). If you modified your MySQL configuration to revert to using /tmp/mysql.sock, the update process will detect that condition and create a symlink in /var/mysql so that the socket can be accessed by PHP. This is done to prevent disruption, and should be considered a temporary measure. At your earliest convenience, you should remove any socket directives from the [mysqld] and [client] sections of your MySQL config files, and allow MySQL to use its default socket location. Then you can restart MySQL; it will remove the symlink from /var/mysql, replace it with the socket, and PHP will continue to have access.

In addition, to remove a barrier to seamless interaction with the Apache web server:

  • The MySQL Manager application now creates the /var/mysql directory (which contains the MySQL socket) with permissions that allow the web server to access it.
  • If that directory already exists, the update process sets the correct permissions.

Products Affected

Mac OS X Server 10.4

For self-installed MySQL

If you have downloaded and installed MySQL yourself but are using the pre-installed version of PHP, note that your custom version of MySQL might be configured to use the old MySQL socket location, /tmp/mysql.sock. The version of PHP in this software update uses the newer location /var/mysql/mysql.sock by default.

Therefore, if your PHP scripts are failing to connect to your custom installation of MySQL, this is a likely cause. To correct this, you can modify the PHP configuration file to use the old MySQL socket location:

  1. Create /etc/php.ini if it is not present. (You can do so by copying /etc/php.ini.default to /etc/php.ini).
  2. Edit the /etc/phi.ini config file, find the [MySQL] section, and change this line:
    mysql.default_socket = /var/mysql/mysql.sock
    To:
    mysql.default_socket = /tmp/mysql.sock
  3. Restart the web server to pick up the new PHP settings. It should not be necessary to restart MySQL.

If you subsequently decide to use the version of MySQL that is pre-installed with Mac OS X Server, which uses /var/mysql/mysql.sock, you'll want to either remove that line from /etc/php.ini, or change it back.

Not helpful Somewhat helpful Helpful Very helpful Solved my problem