nginx tips for localhost development

Francis Daly francis at daoine.org
Mon Apr 15 17:49:22 UTC 2013


On Sun, Apr 14, 2013 at 10:50:15PM -0400, Ian M. Evans wrote:

Hi there,

> I've realized that it would probably be wise to develop locally by running
> a localhost server in a linux VM on my laptop and desktop.
> 
> Can anyone give me any tips (or point me to a tutorial/article) that would
> show me how to set up nginx for localhost testing? Is it possible for me
> to create a setup in nginx so both www.example.com and
> www.mynewsiteexample.com would be served by the localhost nginx?

On the nginx side, there should be approximately nothing special to do.

The nginx.conf that works on your production server can be put onto your
development server; "listen" directives which specify ip addresses may
need to be changed, and file names may need to be changed if you have
a different layout.

But other than that, not much about nginx cares.

The main thing you will need, if you use multiple server{} blocks with
different server_name directives, is to make sure that whatever client
you are testing with (== web browser) resolves the names that you use
to be an address that your test nginx listens on. /etc/hosts is probably
the simplest way to arrange that.

If you're comfortable testing using "curl", you don't even need that --
just add a suitable "-H Host:" argument to each command.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list