Christian Mayer's Weblog

OS X Development Setup

You heard about Vagrant and VirtualBox as web development environments. There is a proper Vagrant-everything movement. Basically it’s not a bad idea to Vagrant everything you code. Especially on webapplications, or maybe on software you don’t trust.

But in some cases you don’t want to use Vagrant and VirtualBox. One of this cases is when your PC has not the power to run VirtualBox, or maybe it has the power but VirtualBox is still running too slow for your requirements. In this case you run your developement environment without VirtualBox, without Vagrant — straight on OS X. Here is how you do it.

Apache

There is already an Apache server installed on your Mac. The configuration files are located under /etc/apache2 path. You can start (and stop) it with apachectl:

$ apachectl start

Consider using the sudo command or switch to root-user when editing configuration files under /etc or when starting, stopping, restarting system processes like Apache or MySQL. I will not discuss this in detail because I assume that you are familiar with root access.

If you need to run PHP you need to activate the PHP module for Apache manually in /etc/apache2/httpd.conf — line ~169:

#LoadModule php5_module libexec/apache2/libphp5.so

Optional you need to change the user at line ~182:

User _www
Group _www

Remove the prepended # character and restart Apache:

$ apachectl restart

By the way, if you use a relative module path it’s relative to path /usr. For example libexec/apache2/libphp5.so is located under /usr/libexec/apache2/libphp5.so.

If you want to use another version of PHP installed by Homebrew replace the line with the following:

LoadModule php5_module /usr/local/Cellar/php56/5.6.17/libexec/apache2/libphp5.so

Depending on which version you installed the path can differ.

PHP7

Also PHP7 is now available via Homebrew:

$ brew install php70

To use PHP7 under Apache you need to remove the LoadModule php5_module line in the Apache config file with:

LoadModule php7_module /usr/local/Cellar/php70/7.0.2/libexec/apache2/libphp7.so

As always, depending on which version you installed the path can differ.

There is a file under /etc/apache2/other/php5.conf. Copy it for PHP7:

$ cp /etc/apache2/other/php5.conf /etc/apache2/other/php7.conf

and replace the first line <IfModule php5_module> in php7.conf with:

<IfModule php7_module>

As always after config changes, restart your Apache process:

$ apachectl restart

MySQL

Install MySQL via Homebrew:

$ brew install mysql
$ mysql_secure_installation

Follow the output after the installation. Start the MySQL server:

$ mysql.server start

Sometimes I’m using Sequel Pro to inspect the MySQL database under OS X. Don’t get confused by the Pro included in the name of Sequel Pro. You don’t need to pay for it, it’s for free.

Elasticsearch

Elasticsearch is available via Homebrew. Install Java first:

$ brew install Caskroom/cask/java
$ brew install homebrew/versions/elasticsearch17

As always, follow the output after the installation:

$ elasticsearch --config=/usr/local/opt/elasticsearch17/config/elasticsearch.yml

Posted on .
Categories: Productivity, Programming
Tags: Development, Vagrant, VirtualBox, Web, Application, Software, Oracle, Homebrew, SQL, MySQL, Sequel Pro, Elasticsearch

Categories | RSS Feed | Usage | Imprint
Copyright © 2006 by