Loading...
 
Create a Mac IDE using Homebrew (Cached) Type of page »  Developers documentation

Mac Development System With Homebrew

How to install Apache, PHP (with xdebug) and MySQL on a Mac using Homebrew, a software package manager for MacOS X. The list of available software packages can be found at braumeister.org, although there are more "taps" available at other repositories.

The Mac already comes with Apache and PHP installed, but if you want to be able to upgrade to more recent versions you can use Homebrew to install these. Also, starting with the OS Sierra, the built-in Apache is more difficult to use due to some missing scripts. MacOS X doesn't include MySQL.

 

These instructions are based on the excellent blog post at https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions. That page also has useful instructions on how to install and switch between multiple PHP versions.

Before Installing Homebrew

  1. Remove MacPorts or Fink, if these are installed
    • Macports
      sudo port -f uninstall installed
      sudo rm -rf /opt/local
      sudo rm -rf /Applications/DarwinPorts


    • Fink (untested)
      fink remove --recursive daemonic xinitrc
      sudo rm -rf /sw


  2. Make sure Xcode and the Command Line Tools of Xcode are installed
    • Depending on your version, command line tools can be installed in two ways:
      1. In Xcode, go to Preferences > Downloads > Command Line Tools and click install
      2. In Terminal, type xcode-select --install and then click install on the pop-up

Install Homebrew

  1. Type the following in Terminal to install Homebrew:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


  2. Run the command to check your installation:
    brew doctor
    • There may be several errors but Homebrew has pretty good explanations of how to fix them


  3. Make sure brew is up to date (if brew was already installed):
    brew update

Install Apache

Enter the following in Terminal:

  1. Turn off built-in Apache
    sudo apachectl stop
    sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null


  2. Install Homebrew Apache
    brew install httpd


  3. Set up Apache to autostart upon reboot
    brew services start httpd


  4. Test that Apache is working by pointing your browser to http://localhost:8080 . You should see a simple header that says "It works!".

  5. Troubleshooting tips if the browser can't connect
    #check if server is up
    ps -aef | grep httpd
    #restart Apache
    brew services restart httpd
    # watch Apache log
    tail -f /usr/local/var/log/httpd/error_log


Configure Apache

Make the following changes in /usr/local/etc/httpd/httpd.conf :

  1. Change the listen port from the brew default of Listen 8080 to Listen 80

  2. Change the document root
    #if using the global root
    DocumentRoot "/Library/WebServer/Documents"
    #if using the user home directory
    DocumentRoot "/Users/username/Sites"


  3. Set the Directory tag to the same root
    #if using the global root
    <Directory "/Library/WebServer/Documents">
    #if using the user home directory
    <Directory "/Users/username/Sites">


  4. Set AllowOverride within the same Directory tag to All
    AllowOverride All


  5. Enable rewrite module (disabled by default)
    • Uncomment the line that says LoadModule rewrite_module libexec/mod_rewrite.so


  6. Change User and Group
    • By default these are set to daemon. Change to _www or actual user and group names to avoid permission problems.


  7. Set the server name: ServerName localhost

Install PHP

  1. In Terminal, enter the following commands:
    # install php (dependencies will also be installed)
    # this will install latest version
    # use @ to install a specific verion, like php@7.2
    brew install php
    # if using imagick php extension, first install imagemagick itself using homebrew, then install the php extension using pecl
    brew install imagemagick
    pecl uninstall -r imagick && pecl install imagick
    # see below regarding installing xdebug

    Note that "php@7.2" is just an example for PHP version 7.2. Change according to the version you intend to install.

  2. Make changes to Apache configuration at /usr/local/etc/httpd/httpd.conf to use newly installed PHP version
    # Add php load module command
        LoadModule php7_module    /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so
    # Set directory indexes to PHP by changing the DirectoryIndex options
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>
    # Add FilesMatch directive
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Install Xdebug PHP Extension

This section assumes you've installed PHP in the previous step.

  1. In Terminal, enter the following command:
    pecl uninstall -r xdebug && pecl install xdebug


  2. In the php.ini file, add the following lines:
    (look at phpinfo to see where the file is located)
    xdebug.remote_enable=1
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
    xdebug.remote_host="localhost"


  3. Restart Apache by entering the following command in Terminal (you may be prompted for a password):
    brew services restart httpd

Install MySQL

  1. In Terminal, enter the following command:
    brew install mysql

  2. Follow Homebrew instructions for launching
    • Enter brew services restart mysql following the other Homebrew instructions (but before setting running mysql_secure_installation ):
    • If you have problems restarting the mysql server, try restarting your computer.

  3. Set a password to avoid errors. Enter the following and follow the prompts:
    mysql_secure_installation

Check versions

  1. In Terminal, enter one of the following commands (lines beginning with # are just descriptions):
    #list versions of all programs installed by home-brew
    brew list --versions  
    
    or
    
    #show the version of a single program
    brew list --versions mysql

Update programs

  1. In Terminal, enter the following command choices (the purpose for each command follows the # symbol - you only need to type the part before the #):
    brew update  #first update homebrew itself
    brew outdated  #list what is outdated
    brew upgrade  #upgrade everything
    brew upgrade mysql  #or upgrade a specific program

Remove old versions of programs

  1. By default Homebrew leaves the old version intact when updating program. To remove them, type the following in Terminal:
    # to see what would be removed (without removing anything)
    brew cleanup -n
    
    # to remove all old versions of all programs
    brew cleanup
    
    # to remove the old versions for just one program
    brew cleanup mysql

Uninstall programs

  1. For php, each new version branch (moving from 7.0 to 7.1, for example) is a separate program in homebrew. Unlinking the program as shown above still keeps it on your system so you need to perform an uninstall to remove it
    brew uninstall php@7.0
Page last modified on Sunday 12 August, 2018 20:58:38 GMT-0000

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.

Accessibility (WAI & 508)
Accounting
Administration
Ajax
Articles & Submissions
Backlinks
Banner
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution
Cookie
Copyright
Credits
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping
Mobile
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment
PDF
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Scheduler
Score
Search engine optimization (SEO)
Search
Security
Semantic links
Share
Shopping Cart
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
Webmail and Groupmail
WebServices
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives
WYSIWTSN
WYSIWYCA
WYSIWYG
XMLRPC
XMPP




Useful Tools