Enabling Apache, PHP and MySql in Mac Leopard

10:33 pm PHP

Just got my first Mac yesterday and try to get PHP and Mysql to work so I can start to do my assignment. PHP is disabled by default and the value of mysql.default_socket is empty.

Let’s start with PHP:

  • Open /etc/apache2/httpd.conf using text editor with root account. e.g. sudo vi /etc/apache2/httpd.conf
  • Search for LoadModule php5_module and uncomment the line
  • If index.php is not included as default index file, search for dir_module, add index.php as Directory Index
    [html]<IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
  • Save and close httpd.conf

Now MySql:

  • Get MySql package for Mac and download and install in your Mac by following the instruction
  • Move directory to /etc, current php.ini.default does nothing and for PHP to read the ini file, the file must be renamed to php.ini. But instead of renaming, just copy the file with sudo cp php.ini.default php.ini.
  • Using text editor to open php.ini as root e.g. sudo vi php.ini and look for mysql.default_socket.
  • set the value of mysql.default_socket = /tmp/mysql.sock
  • Save and Close the file

Now restart Apache using:
sudo /usr/sbin/apachectl restart

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.