Loading...
 
Skip to main content

History: Mac IDE Without XAMPP

Source of version: 48 (current)

Copy to clipboard
! 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.
{REMARKSBOX(type="warning" title="Later Versions")}''Please note that some procedures differ than documented here when using or upgrading to the Mountain Lion (10.8) or Mavericks (10.9) Mac operating system version. Please see the following articles for more information when using or upgrading to these versions: [http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion|Mountain Lion (10.8)], [http://www.coolestguidesontheplanet.com/downtown/get-apache-mysql-php-and-phpmyadmin-working-osx-109-mavericks|Mavericks (10.9)], and [http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/|Yosemite (10.10)].''{REMARKSBOX}
{REMARKSBOX(type="tip" title="An alternative")}Another approach to manage and install the software needed to create an IDE on a Mac is to use a package manager like [http://macports.org|macports] or [http://brew.sh|Homebrew], which are similar to [http://en.wikipedia.org/wiki/Advanced_Packaging_Tool|APT] on other platforms. Full details to come on a separate ((Mac Development System With MacPorts)) and ((Mac Development System With Homebrew)) pages.{REMARKSBOX}

{REMARKSBOX(type=tip, title=Tip)}''This page is a summary of the excellent articles at [http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/] and [http://superfancy.net/coding/mysql-administrator-on-mac-osx-leopard-tips-and-tricks/].''{REMARKSBOX}
!!!# Make sure hidden files are visible
Do this either through the proper setting on your editor, or by this Terminal command (restarting Finder afterwards):
{CODE(wrap="1" colors="shell")}defaults write com.apple.finder AppleShowAllFiles TRUE{CODE}
!!!# Enable PHP
# Browse to Apache's -+http.conf+- file located at  -+/etc/apache2/httpd.conf+- and find this line:
+ {CODE(wrap="1" colors="php")}#LoadModule php5_module libexec/apache2/libphp5.so{CODE}
+
# Remove the # symbol at the beginning of the line so that it reads
+ {CODE(wrap=1, colors=apache)}LoadModule php5_module libexec/apache2/libphp5.so{CODE}
+
# 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:
+{CODE(wrap="1" colors="shell")}sudo cp /etc/php.ini.default /etc/php.ini{CODE}
+
!!!# 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:
+
+{img fileId=9 thumb=mouseover}
+ %%%
# 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
+ {REMARKSBOX(type="tip" title="Tip")}''If you use the personal website (with -+~''yourusername''+- in the path) and you have problems logging in, use the computer website path (number 1 above).''{REMARKSBOX}
+
# 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 the -+conf+- file with your user name. It will be named -+''yourusername''.conf+-
++ %%%
## Add the following and then save it (you'll need to stop and restart Apache after saving the file):
++ {CODE(wrap="1" colors="xml")}<directory "/Users/yourusername/Sites/*/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</directory>{CODE}
!!!# Test PHP
# Create a PHP file with the following code:
+{CODE(colors="php")}<?php 
phpinfo(); 
{CODE}
+
# 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:
+
+ {img fileId=10 thumb=mouseover style=border}
!!!# 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:
++ {CODE(colors=ini)}mysql.default_socket = /tmp/mysql.sock 
pdo_mysql.default_socket= /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock{CODE}
++
## For MySQL, create a file at -+/etc/my.cnf+- with the following:
++ {CODE(colors=ini)}[client]
socket = /tmp/mysql.sock

[mysqld]
socket = /tmp/mysql.sock{CODE}
!!!# 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 {DIV(type=span, class=inline_syntax)}mysql.sock{DIV} 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:
++ 
++ {img fileId=12 thumb=mouseover}
+ 
# MySQL Workbench
+ %%%
## Download from [http://dev.mysql.com/downloads/mysql/] and install
++ %%%
## Set the ''Connection Method'' to {DIV(type=span, class=inline_syntax)}Local Socket/Pipe{DIV} and add the correct ''Socket/Pipe Path'' as shown in this screenshort:
++
++ {img fileId=13 thumb=mouseover}
++ %%%
## Once you've created a connection, double click on it and click ''Add Schema'' under ''Actions'' in the left panel to create a database
!!!# 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+-:
+ {CODE(wrap=1, colors=ini)}zend_extension= /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so{CODE}
+
# 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