Archive for the ‘Programming’ Category

Installing MySQL on OS X

Unfortunately OS X doesn’t comes with MySQL installed. To create your lamp stack on OS X, first you need to get the MySql database from MySQL AB. Installation is straight forward. But don’t forget to install the Mysql.pref which adds a preferences pane to System preferences for starting and stopping the server.

After installation to test your configuration open up a terminal and type

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

If you get prompt like the following. You got your Mysql database running.

$ /usr/local/mysql/bin/mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51b MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


Enabling PHP in Mac OS X

Mac OS X comes with everything a web developer needs. Php, Perl, Ruby, Apache. But they are not activated by default to get your Apache to play nice with default PHP install of OS X. Follow these steps.

Open file called “httpd.conf” which is located under “/private/etc/apache2/” with your favourite editor.


Or, open up a terminal and type,

sudo vim /private/etc/apache2/httpd.conf

Move to line “around 114″ at the end of LoadModule section it should print

#LoadModule php5_module        libexec/apache2/

Remove the # symbol to uncomment that line.

LoadModule php5_module        libexec/apache2/

Now apache knows about your php module. Go to you System Preferences then sharing and turn on web sharing. To test your installation create a file called hello.php with the following code snippet and place it in /Sites/

Print "Hello, World!";

If everything went fine going to in your browser should print Hello, World!.