Apache PHP MySQL on Mac OS X 10.6

By deptz, Tue. November 23, 2010
Categories: mac, tutorial
Tags: , , ,
327 views

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 Responses to “Apache PHP MySQL on Mac OS X 10.6”

  1. Pencerah Says:

    nice info

  2. deptz personal blog » Blog Archive » Enable Mod Rewrite on Snow Leopard Says:

    […] enable Apache and PHP (also installing MySQL) on my macbook, i want to enable mod rewrite (Rewrite engine) .  From wikipedia, Mod rewrite […]

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

    […] pernah menulis tentang cara menginstall dan konfigurasi Apache, PHP dan MySQL di OS X 10.6 Snow Leopard. Dan dua hari yang lalu saya mengupdate OS saya […]

  4. Update OS X: Maverick - deptz personal blog Says:

    […] installasi selesai, tidak ada data maupun software yang hilang, Hanya saja untuk  PHP membutuhkan setting ulang. Selebihnya semua sudah berjalan seperti […]

Comments