Running Nginx on OS X is becoming a more attractive alternative to running some of the standard stacks that developers use to set up their environments.

That is, I think many of us are used to running something like this following:

  • Apache
  • MySQL
  • PHP
  • WordPress

That works because the majority of our hosts have these configurations, and it’s a good practice to have our development environment mirror our staging and production environments.

But Nginx is becoming a popular alternative to Apache and other web servers, so we need to update our local machines accordingly.Getting it set up on OS X takes a little more work.

Getting it set up on OS X takes a little work.

Running Nginx on OS X

Many WordPress developers opt to use MAMP or VVV to set up their development environments both of which are reliable alternatives.

But what do you, especially if you’re running MAMP? In other words, what do you do if you want to run Nginx alongside Apache? In that case, check out this short guide by @raamdev.

Running Nginx on OS X - A Gist of Instructions

In a nutshell, the guide captures the following steps:

  1. Installing MacPorts
  2. Updating the relevant files and constants on your machine
  3. Defining Nginx configuration
  4. Starting the server

For those who have been working in environments such as Digital Ocean, then I recommend at least experimenting with this setup.

Personally, I don’t think it’s necessary if you know what you’re doing in both your development and staging or production environments. But if you want to make sure the environments mirror each other as closely as possible, or you may wish to experiment with running Nginx locally. If so, then this is an excellent resource for getting started with exactly that.

If you have alternative resources for setting Nginx up on OS X, feel free to share the in the comments (as I know there are a variety of tools available). In the meantime, check out the guide above. It’s one of the best I’ve found.

Category:
Resources
Tags:

Join the conversation! 4 Comments

  1. After a week of using VVV for local development, you’d have never been able to convince me to do anything differently.

    I’m a little miffed that PHP 7 support hasn’t been added yet, but it’s easy enough to modify the Vagrant box and make it work.

    • After a week of using VVV for local development, you’d have never been able to convince me to do anything differently.

      I’m still half-and-half on this. If a site is using Nginx and a similar stack, then go for it! I think setup is a bit more than it should be but that can always be improved over time, you know?

      If the stack is traditional LAMP, then more turnkey solutions still work okay, IMHO.

      I’m a little miffed that PHP 7 support hasn’t been added yet, but it’s easy enough to modify the Vagrant box and make it work.

      The performance improvements in PHP7 should not be ignored, right? I’ve been really impressed with how certain sites I have run on Nginx and PHP7 with no caching.

  2. I’ve tried MAMP, MAMP Pro, and my own configured Nginx (and PHP-FPM, MySQL etc. mostly setup via Homebrew) on my Mac.

    To be honest, this wasn’t worth all the effort it involved; Salty WordPress (https://github.com/humanmade/Salty-WordPress) / another Vagrant box is far easier to manage in the long run and has the added benefit than it’s really easy to handover to a colleague.

    If your local development doesn’t match your production environment, you’re likely to run into issues and spending more time on bug fixing when you deploy to your staging / production environment.

    • I’ve tried MAMP, MAMP Pro, and my own configured Nginx (and PHP-FPM, MySQL etc. mostly setup via Homebrew) on my Mac.

      It’s both funny and sad how much time we’ll take to experimenting with setting up environments isn’t it?

      To be honest, this wasn’t worth all the effort it involved; Salty WordPress (https://github.com/humanmade/Salty-WordPress) / another Vagrant box is far easier to manage in the long run and has the added benefit than it’s really easy to handover to a colleague.

      I’ve not heard of Salty — but it’s something I’m going to look into :).

      If your local development doesn’t match your production environment, you’re likely to run into issues and spending more time on bug fixing when you deploy to your staging / production environment.

      +1

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.