-
Notifications
You must be signed in to change notification settings - Fork 5
How to setup a local MEDUSA development environment on your Mac using Homebrew
For those that would like to run MEDUSA locally on their Mac without using Docker, Vagrant or some other virtual machine
- Xcode
- Command Line Tools for Xcode
-
If needed, install Xcode via the App Store, and execute sudo xcodebuild -license if required.
-
If needed, open a terminal windows on your Mac and install Command Line Tools for Xcode
$ xcode-select --install
-
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)"
-
Install MongoDB, Redis and PHP 7.3
$ brew install mongodb redis php
-
Symlink PHP 7.1
$ brew link --force php
- 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
-
Install nginx, node, imagemagick, pkg-config, composer and sass
$ brew install nginx node imagemagick pkg-config composer sassc
-
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"
-
Configure php-fpm. Edit
/usr/local/etc/php/7.3/php-fpm.d/www.conf
and change the listen line tolisten = /usr/local/var/run/php-fpm.sock
-
Clone the MEDUSA repo in the directory of your choice (~/sites is good choice)
$ git clone https://github.com/TRMN/medusa.git
-
Copy .env.example to .env
$ cd ~/sites/medusa
$ cp .env.example .env
- Install the required PHP dependencies.
$ cd ~/sites/medusa
$ composer install
- Install the required node dependencies to generate css from scss files and to minify javascript.
$ cd ~sites/medusa
$ npm install
$ npm audit fix
-
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. -
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
-
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
- 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 .
-
Verify that everything is working by going to http://medusa.local:8080/ in your browser. Use your current medusa login.
-
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