Hacker News new | past | comments | ask | show | jobs | submit login

I've always used Apache but I really want to use nginx for my next project (it's a Node/express app). How should I start? It'll be running on my Ubuntu VPS. Any tips, suggestions, common pitfalls?



The only pitfall that I've run into is converting Apache rewrite rules (htaccess) files and getting that into the nginx configuration file.

For sure, the configuration file format is different, but it's not terribly complicated.


Once you get used to it, it's a lot nicer to work with, too.


I whole heartedly agree - htaccess and virtual host rules were such a pain in Apache, I've really come to appreciate how easy it was to get nginx setup in comparison.


There's really not that much to it. Use nginx that comes from APT and use a unix socket to communicate between node and nginx.

I use this code to open a unix socket in production at tmp/socket : https://gist.github.com/lgbr/5453355

And use a configuration like this for nginx (replace /etc/nginx/sites-available/default with this): https://gist.github.com/lgbr/5453375


    sudo apt-get install nginx
    $BROWSER http://wiki.nginx.org/Configuration
    $EDITOR /etc/nginx/nginx.conf
    man nginx
    man upstart
    sudo start nginx
    $BROWSER http://localhost:$PORT/


> sudo apt-get install nginx

If you want the newest version, nginx has their own deb repository[1]. It seems to get security updates faster, too.

[1] http://wiki.nginx.org/Install#Official_Debian.2FUbuntu_packa...

EDIT: Not the PPA because it's "maintained by volunteers and is not distributed by nginx.org." Their repository:

deb http://nginx.org/packages/ubuntu/ yourOScodename nginx


I was using a ppa at one point, but reverted when the distro packaged a new enough version.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: