Loading...
 
Skip to main content
Use the Mac's native PHP and Apache to create an IDE

Mac IDE Without XAMPP

Create a Mac IDE Without XAMPP

Mac's operating system OS X (Leopard and later) comes with PHP and Apache already installed, so the only additional programs needed to set up a Mac as a local server for development purposes are MySQL and a database interface program. This page explains how to configure and install these components, based on the Snow Leopard operating system.

Make sure hidden files are visible

Do this either through the proper setting on your editor, or by this Terminal command (restarting Finder afterwards):

Copy to clipboard
defaults write com.apple.finder AppleShowAllFiles TRUE

1.1.2. Enable PHP

  1. Browse to Apache's http.conf file located at /etc/apache2/httpd.conf and find this line:
    Copy to clipboard
    #LoadModule php5_module libexec/apache2/libphp5.so

  2. Remove the # symbol at the beginning of the line so that it reads
    Copy to clipboard
    LoadModule php5_module libexec/apache2/libphp5.so

  3. Save the httpd.conf file

  4. Activate the default php.ini file by renaming /etc/php.ini.default to /etc/php.ini by typing the following command in the Terminal window:
    Copy to clipboard
    sudo cp /etc/php.ini.default /etc/php.ini

1.1.3. Enable Apache

  1. Open the Mac's System Preferences and click on Sharing in the Internet & Wireless section

  2. In the pop-up, click on Web Sharing to enable Apache. Here's a screenshot:

    Image

  3. Note the addresses for your computer and personal websites. The IP number in the address can be replaced with localhost as follows:

    1. http://localhost equates to /Library/WebServer/Documents in Finder (this is not the Library folder found in your home directory)

    2. http://localhost/~yourusername equates to /Users/yourusername/Sites in Finder


  4. If you're using your personal website (number 2 above), you may need to modify the Apache configuration file:

    1. Go to /etc/apache2/users/ and edit the conf file with your user name. It will be named yourusername.conf

    2. Add the following and then save it (you'll need to stop and restart Apache after saving the file):
      Copy to clipboard
      <directory "/Users/yourusername/Sites/*/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </directory>

1.1.4. Test PHP

  1. Create a PHP file with the following code:
    Copy to clipboard
    <?php phpinfo();

  2. Save in /Library/WebServer/Documents or /Users/yourusername/Sites, depending on whether you are using the computer or personal website (you may need to use the first one to avoid login problems).

  3. Navigate you browser to this file. You've succeeded when you a screen like the following:

    Image

1.1.5. Install and Configure MySQL

  1. Go to http://dev.mysql.com/downloads/mysql/, download the appropriate version and install it

  2. Also install the MySQL Preference Pane available in the same download. It will allow you to stop and start MySQL from Mac's System Preferences window

  3. PHP and MySQL communicate through the mysql.sock file, which is installed at -+/tmp/mysql.sock=- by default. Be sure both programs are configured to look for the file here (or wherever you want to move the file to) by doing the following:

    1. For PHP, ensure the following is set in the /private/etc/php.ini file:
      Copy to clipboard
      mysql.default_socket = /tmp/mysql.sock pdo_mysql.default_socket= /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock

    2. For MySQL, create a file at /etc/my.cnf with the following:
      Copy to clipboard
      [client] socket = /tmp/mysql.sock [mysqld] socket = /tmp/mysql.sock

1.1.6. Install and Configure a MySQL Interface

If you'd like to be able to inspect the database, you'll need to install a separate interface program. Below are a couple of free ones with tips on how to set up. The main thing in both cases is to tell the program where the mysql.sock file is.

  1. Navicat for MySQL Lite

    1. Download from http://www.navicat.com/ and install

    2. When configuring a new connection, indicate the mysql.sock path in the Advanced tab. Here's a screenshot:

      Image

  2. MySQL Workbench

    1. Download from http://dev.mysql.com/downloads/mysql/ and install

    2. Set the Connection Method to Local Socket/Pipe and add the correct Socket/Pipe Path as shown in this screenshort:

      Image

    3. Once you've created a connection, double click on it and click Add Schema under Actions in the left panel to create a database

1.1.7. Aptana Studio Settings

The instructions at XAMPP-Aptana can be used to configure Aptana with appropriate changes to file locations since XAMPP is not being used here. Here are a couple of tips:

  1. Set the PHP Executable to be /usr/bin/php

  2. Place the Xdebug file (download from http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging) at the location indicated in the following entry that should be made to /private/etc/php.ini:
    Copy to clipboard
    zend_extension= /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so

  3. Under File > Switch Workspace, set the workspace to be /Library/WebServer/Documents or /Users/yourusername/Sites, depending on the location chosen in step 3.3.


Show PHP error messages