Lion Server: Configuring PHP for MySQL

Learn how to configure PHP for MySQL in Lion Server.

This article has been archived and is no longer updated by Apple.

Lion Server no longer includes MySQL by default. If you want to use MySQL with PHP in Lion Server, you may need to manually reconfigure your PHP installation.

You must explicitly define the following values in /etc/php.ini.

The default TCP port for MySQL is traditionally 3306, so mysql.default_port, mysqli.default_port and pdo_mysql.default_port should all be defined with this value.

The traditional MySQL socket on previous Mac OS X Server versions was /var/mysql/mysql.sock, which is appropriate for systems that continue to use the Apple-provided 5.0 installation migrated from Mac OS X Server v10.5 or v10.6. If you have installed MySQL from, the default socket is /tmp/mysql.sock. The directives mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket should all be defined with the path that matches your installation.

The versions of PHP delivered with Mac OS X Server v10.6 and Lion Server can also communicate to a remote MySQL server without MySQL or any of its libraries being installed on the local computer. To do so, define mysql.default_host, mysqli.default_host or pdo_mysql.default_host to the default remote host.

For more information about available MySQL directives, see:

Note that PHP and MySQL recommend the use of PHP's mysqli APIs instead of PHP's mysql APIs to take advantage of MySQL's latest features:

Important: Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. Apple provides this only as a convenience to our users. Apple has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and Apple assumes no responsibility in this regard. Please understand that a third-party site is independent from Apple and that Apple has no control over the content on that website. Please contact the vendor for additional information.
Published Date: