Apache PHP MySQL on Mac OS X 10.6

By default, Mac OS X come with preinstalled Apache and PHP. But for a while, i’m using XAMPP for Mac in my macbook because in my first time using Mac OS, i don’t know about it.

Yesterday, i tried to using preinstalled Apache and PHP, also adding MySQL. For enable Apache, it just take a click. Go to System Preferences -> Sharing

Enable Apache

Enable Apache

Done! ๐Ÿ™‚

For enable PHP, use your favorite text editor, and edit file /etc/apache2/httpd.conf

  1. Here I’m using TextWrangler. Open Terminal, and type:
    sudo open -a TextWrangler /etc/apache2/httpd.conf
    
  2. Then remove # in the front of
    LoadModule php5_module        libexec/apache2/libphp5.so
    
  3. copy default php.ini configuration with this command:
    cp /private/etc/php.ini.default /private/etc/php.ini
  4. Edit timezone setting to your correct timezone
    date.timezone = 
    
  5. Then just disable and then enable Web Sharing. Done! ๐Ÿ™‚
  6. For test your installation, just create a new file named info.php and save it into <your username>/Sites/
    <?php phpinfo(); ?>
    
  7. And open your browser, go to http://localhost/~<your username>/info.php, for example in my user (pujipriyono) http://localhost/~pujipriyono/info.php
PHP Info

PHP Info

Installing MySQL need more click and edit. But it is easy. ๐Ÿ™‚

  1. Download MySQL Installer from here
  2. Install everything in the package in this order: mysql, the startup item, the preference pane.
  3. In /etc/php.ini, replace the three occurences of /var/mysql/mysql.sock by /tmp/mysql.sock
    pdo_mysql.default_socket=/tmp/mysql.sock
    mysql.default_socket = /tmp/mysql.sock
    mysqli.default_socket = /tmp/mysql.sock
    
  4. Then disable Web Sharing, enable it again and start MySQL in the preference pane. Done ๐Ÿ™‚

Reference: maestric.com

4 thoughts on “Apache PHP MySQL on Mac OS X 10.6

  1. Pingback: deptz personal blog » Blog Archive » Enable Mod Rewrite on Snow Leopard

  2. Pingback: deptz personal blog » Blog Archive » Konfigurasi Apache, PHP dan MySQL di OS X 10.8 Mountain Lion

  3. Pingback: Update OS X: Maverick - deptz personal blog

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.