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):
defaults write com.apple.finder AppleShowAllFiles TRUE
1.1.2. Enable PHP
- 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
- Remove the # symbol at the beginning of the line so that it reads
Copy to clipboardLoadModule php5_module libexec/apache2/libphp5.so
- Save the
httpd.conf
file
- 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 clipboardsudo cp /etc/php.ini.default /etc/php.ini
1.1.3. Enable Apache
- Open the Mac's System Preferences and click on Sharing in the Internet & Wireless section
- In the pop-up, click on Web Sharing to enable Apache. Here's a screenshot:
- Note the addresses for your computer and personal websites. The IP number in the address can be replaced with
localhost
as follows:
-
http://localhost
equates to/Library/WebServer/Documents
in Finder (this is not the Library folder found in your home directory)
-
http://localhost/~yourusername
equates to/Users/yourusername/Sites
in Finder
TipIf you use the personal website (with~
yourusername in the path) and you have problems logging in, use the computer website path (number 1 above).
-
- If you're using your personal website (number 2 above), you may need to modify the Apache configuration file:
- Go to
/etc/apache2/users/
and edit theconf
file with your user name. It will be namedyourusername.conf
- 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>
- Go to
1.1.4. Test PHP
- Create a PHP file with the following code:
Copy to clipboard<?php phpinfo();
- 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).
- Navigate you browser to this file. You've succeeded when you a screen like the following:
1.1.5. Install and Configure MySQL
- Go to http://dev.mysql.com/downloads/mysql/, download the appropriate version and install it
- 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
- 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:
- For PHP, ensure the following is set in the
/private/etc/php.ini
file:
Copy to clipboardmysql.default_socket = /tmp/mysql.sock pdo_mysql.default_socket= /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock
- 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
- For PHP, ensure the following is set in the
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.
- Navicat for MySQL Lite
- Download from http://www.navicat.com/ and install
- When configuring a new connection, indicate the
mysql.sock
path in the Advanced tab. Here's a screenshot:
- Download from http://www.navicat.com/ and install
- MySQL Workbench
- Download from http://dev.mysql.com/downloads/mysql/ and install
- Set the Connection Method to Local Socket/Pipe and add the correct Socket/Pipe Path as shown in this screenshort:
- Once you've created a connection, double click on it and click Add Schema under Actions in the left panel to create a database
- Download from http://dev.mysql.com/downloads/mysql/ and install
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:
- Set the PHP Executable to be
/usr/bin/php
- 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 clipboardzend_extension= /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
- 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.