Skip to content

How to setup a local MEDUSA development environment on your Mac using Homebrew

Dave Weiner edited this page May 4, 2019 · 2 revisions

For those that would like to run MEDUSA locally on their Mac without using Docker, Vagrant or some other virtual machine

Prerequisites

  • Xcode
  • Command Line Tools for Xcode

Step-by-step guide

  1. If needed, install Xcode via the App Store, and execute sudo xcodebuild -license if required.

  2. If needed, open a terminal windows on your Mac and install Command Line Tools for Xcode

    $ xcode-select --install

  3. Open a terminal window on your Mac and install Homebrew (https://brew.sh/) using this command:

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

  4. Install MongoDB, Redis and PHP 7.3

    $ brew install mongodb redis php

  5. Symlink PHP 7.1

    $ brew link --force php

  1. Make sure that this installation of PHP comes first in the path
     $ echo 'export PATH="/usr/local/opt/php/bin:$PATH"' >> ~/.bash_profile
     $ echo 'export PATH="/usr/local/opt/php/sbin:$PATH"' >> ~/.bash_profile
     $ source ~/.bash_profile
  1. Install nginx, node, imagemagick, pkg-config, composer and sass

    $ brew install nginx node imagemagick pkg-config composer sassc

  2. Install required PHP modules. Accept the default option for any prompts. Make sure you do this in either the same terminal window where you executed source ~/.bash_profile or a new terminal window created after you added the php path to the front of the search path, so pecl will find the correct php.ini file.

     $ pecl install mongodb 
     $ pecl install imagick 
     $ pecl install redis

After the all the modules have been installed, verify that you have the following lines at the top of /usr/local/etc/php/7.3/php.ini before the [PHP]

     extension="imagick.so"
     extension="redis.so"
     extension="mongodb.so"
  1. Configure php-fpm. Edit /usr/local/etc/php/7.3/php-fpm.d/www.conf and change the listen line to

    listen = /usr/local/var/run/php-fpm.sock

  2. Clone the MEDUSA repo in the directory of your choice (~/sites is good choice)

    $ git clone https://github.com/TRMN/medusa.git

  3. Copy .env.example to .env

     $ cd ~/sites/medusa
     $ cp .env.example .env
  1. Install the required PHP dependencies.
     $ cd ~/sites/medusa
     $ composer install
  1. Install the required node dependencies to generate css from scss files and to minify javascript.
     $ cd ~sites/medusa
     $ npm install
     $ npm audit fix
  1. Copy server_configurations/nginx/medusa.dev from your clone to /usr/local/etc/nginx/servers. Edit /usr/local/etc/nginx/servers/medusa.dev and adjust the paths as need.

  2. Edit /etc/hosts and add medusa.local (I’ve had better luck using the .local extension instead of .dev)

    127.0.0.1 localhost medusa.local

  3. Start mongodb, nginx, PHP and redis. This will also configure your Mac to automatically start them when you log in

     $ brew services start mongodb
     $ brew services start php
     $ brew services start nginx
     $ brew services start redis
  1. Expand the archive of the database you’ve been given and cd into the trmn directory created to load the database into your local mongodb server.
     $ cd trmn/
     $ mongorestore --db=trmn --drop .
  1. Verify that everything is working by going to http://medusa.local:8080/ in your browser. Use your current medusa login.

  2. Finally, give yourself ALL_PERMS, USER_MASQ and CONFIG in your local sandbox. Replace “RMN-XXXX-YY” with your RMN number.

     $ php artisan user:addperm RMN-XXXX-YY ALL_PERMS
     $ php artisan user:addperm RMN-XXXX-YY USER_MASQ
     $ php artisan user:addperm RMN-XXXX-YY CONFIG