Version 3 end of life
This version of Silverstripe CMS will not recieve any additional bug fixes or documentation updates. Go to documentation for the most recent stable version.

Mac OSX with Homebrew

This topic covers setting up your Mac as a web server and installing SilverStripe.

OSX comes bundled with PHP, but you're stuck with the version and modules it ships with. If you run projects on different PHP versions, or care about additional PHP module support and other dependencies such as MariaDB, we recommend an installation through Homebrew.

Check out the MAC OSX with MAMP for an alternative installation process which packages up the whole environment into a convenient application.

Requirements

Since we're compiling PHP, some build tooling is required. Run the following command to install Xcode Command Line Tools.

	xcode-select --install
	ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

First we're telling Homebrew about some new repositories to get the PHP installation from:

	brew tap homebrew/dupes
	brew tap homebrew/php
	brew install php55 php55-mcrypt

Have a look at the brew-php-switcher project to install multiple PHP versions in parallel and switch between them easily.

Install the Database (MariaDB/MySQL)

	brew install mariadb
	unset TMPDIR
	mysql_install_db --user=`whoami` --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
	mysql.server start
	'/usr/local/opt/mariadb/bin/mysql_secure_installation'
	ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents

Configure PHP and Apache

We're not installing Apache, since OSX already ships with a perfectly fine installation of it.

Edit the existing configuration at /etc/apache2/httpd.conf, and uncomment/add the following lines to activate the required modules:

	LoadModule rewrite_module libexec/apache2/mod_rewrite.so
	LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
	DocumentRoot "/Users/<user>/Sites"

again replacing <user> with your OSX user name:

	<Directory "/Users/<user>/Sites">
	    Options FollowSymLinks Multiviews
	    MultiviewsMatch Any
	    AllowOverride All
	    Require all granted
	</Directory>

since it makes permissions easier to handle when running commands both from the command line and through the web server. Find and adjust the following options, replacing the <user> placeholder:

	User <user>
	Group staff
	sudo apachectl start
	sudo apachectl restart
	sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

when accessing http://localhost.

SilverStripe Installation

Composer is a dependancy manager for PHP, and the preferred way to install SilverStripe. It ensures that you get the correct set of files for your project. Composer uses the PHP executable we've just installed. It also needs git to automatically download the required files from GitHub and other repositories.

Run curl -sS https://getcomposer.org/installer | php to install the composer executable. We recommend that you make the executable available globally, which requires moving the file to a different folder. Run mv composer.phar /usr/local/bin/composer. More detailed installation instructions are available on getcomposer.org. You can verify the installation by typing the composer command, which should show you a command overview.

Finally, we're ready to install SilverStripe through composer: composer create-project silverstripe/installer /Users/<user>/Sites/silverstripe/. After finishing, the installation wizard should be available at http://localhost/silverstripe. The Homebrew MariaDB default database credentials are user root and password root.

We have a separate in-depth tutorial for Composer Installation and Usage.