OSX: Nginx for laravel

May 2016 · 1 minute read

Why not using homestead? I think it’s (in some cases) a bit of overkill… Installing a virtual machine adds overhead in terms of disk space and run time.

Install nginx

One of the easierst ways is to use homebrew:

brew install nginx

For php I used:

brew install -v --with-fpm php56

Configuration

Homebrew puts the config into /usr/local/etc/nginx/nginx.conf. I modified it a bit to support laravel and rewrites the routes. You will have to update the http.server.root setting and use your path:

Start & Test

nginx -s stop && nginx
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

Enable autostart on boot:

ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents  

Further Commands

nginx            # start  
nginx -s stop    # stop  
nginx -s reload  # restart  

Links

© Christian Hotz-Behofsits. All rights reserved.