1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Nginx. Quick question

Discussion in 'Server Configuration and Hosting' started by jgas, Feb 18, 2014.

  1. jgas

    jgas Active Member

  2. Null

    Null Well-Known Member

    It will help your server process requests more efficiently because NGINX is better at serving static content.
    MattW likes this.
  3. brendanc

    brendanc Active Member

    If you don't know or don't want to put time into learning how to tune nginx, please don't make the switch. It will most certainly cause more problems than it solves.

    NGINX is a completely different animal when it comes to php, etc. and as such should not be treated as a drop-in replacement for apache as a "free" performance boost. It is anything but "drop-in" and requires a lot of time and effort to get working more efficiently than apache.

    If you're not the tweaker type, it's probably best you stick to Apache, or if you're itching to do some upgrading, switch from Apache 2.2 to 2.4 to get a similar I/O process to NGINX (non-blocking).

    I don't say this to scare you off, but just to warn you that it could be a huge headache if you don't know what you're doing.
    nemke likes this.
  4. p4guru

    p4guru Well-Known Member

    best thing to do is setup a test Nginx server and play with it, learn with it, make mistakes with it.. then once comfortable make the switch :)
    Nomy and HittingSmoke like this.
  5. jgas

    jgas Active Member

    I completely agree.
    In fact, nginx has been installed and my server crashed a few hours later.
    So for nox this option is off the table, since I don't have time, unfortunately, to learn.

    Quick question: since my users are in Italy, and my server in the US, I need in some way to give a boost to the site connection.
    I'm thinking in 2 options: litespeed, or maxcdn. What would you recommend?

    Note that I also use cloudflare.

    Thanks =)
  6. HittingSmoke

    HittingSmoke Active Member

    Regional latency isn't something you're going to solve or even alleviate with different server technology. The only solution is to move your server to where your users are or cache your web site somewhere in between (physically).

    Why not just get a host with servers in Europe to solve the problem properly?
  7. Floren

    Floren Well-Known Member

    Very well put/said, eventually people will understand that installing Nginx on their server is not a "set it and forget it" recipe or copy/paste from Internet. Sometimes I get mocked on these forums when I tell people to read the documentation, instead of posting spoon feeds. Thank you for highlighting what is the essence of Nginx.
    I serve my site with OVH from Canada and I get decent times all over the world.
    No Cloudflare or other gimmicks, few examples:
    Checkpoint: Ashburn, VA, USA OK
    Result: 0 - OK Total Time: 0.388 sec.
    Resolve time: 0.000 sec. Total bytes: 27976 bytes
    Connection time: 0.073 sec. Download time: 0.315 sec.

    Checkpoint: Athens, Greece OK
    Result: 0 - OK Total Time: 0.647 sec.
    Resolve time: 0.014 sec. Total bytes: 28055 bytes
    Connection time: 0.149 sec. Download time: 0.484 sec.

    Checkpoint: Auckland, New Zealand OK
    Result: 0 - OK Total Time: 0.882 sec.
    Resolve time: 0.024 sec. Total bytes: 28053 bytes
    Connection time: 0.205 sec. Download time: 0.653 sec.

    Checkpoint: Beijing, China OK
    Result: 0 - OK Total Time: 2.009 sec.
    Resolve time: 0.002 sec. Total bytes: 27976 bytes
    Connection time: 0.397 sec. Download time: 1.610 sec.

    Checkpoint: Berlin, Germany OK
    Result: 0 - OK Total Time: 0.447 sec.
    Resolve time: 0.002 sec. Total bytes: 27976 bytes
    Connection time: 0.107 sec. Download time: 0.338 sec.

    Last edited: Feb 22, 2014
  8. D.O.A.

    D.O.A. Well-Known Member

    I don't read the documentation and I have 400-1300 online at any given time, on one cheapish control panel-less server in the US. It's like a car, you can drive it, put oil in it and stuff around but you don't have to be a mechanic (although irl I am)

  9. HittingSmoke

    HittingSmoke Active Member

    I disagree with the above points because I think they oversell Apache.

    Nginx is not any harder than Apache. If your distro has Nginx packages then it will be just as stable and "drop-in" as Apache is without the LAMP server config helpers. You'll just have to connect Nginx with your PHP handler.

    The reason I say this is because Apache is just as "drop-in" as Nginx as far as fine tuning. Most people just deploy a LAMP server and never give it a second though. The vast majority of Apache servers are very poorly configured for the use case which is one of the reasons Apache gets such a bad rap.

    When it comes down to it there are a few things you need to know about Nginx and if you follow these guidelines you'll get some benefit over Apache:

    1. Don't serve your static assets through your PHP handler. Most distros have this configured in the default vhost already via a static extension regex.

    2. Don't allow arbitrary code execution. This is something Apache is also prone to if configured incorrectly.

    3. Don't copy location blocks from Google that contain "if" statement unless you understand them in detail.

    One thing Nginx has over Apache is that all of these points are covered in official documentation in the Nginx Pitfalls article. If you can get Nginx to work without running into any of those problems you'll be just fine.
  10. Tracy Perry

    Tracy Perry Well-Known Member

    Can't really complain about mine (China showed 0.00 - but that's because all traffic from them is dropped). Server is based in Florida with ServerComplete.

  11. brendanc

    brendanc Active Member

    I guess we can agree to disagree here then, because NGINX is definitely developer-oriented out of the box whereas Apache is much more user friendly and configuration is much easier to understand.

    I'm not "overselling" Apache in this instance--I run NGINX just fine myself and have championed/maintained it at several of my employers for both development and production servers. It is not however, for the faint of heart.

    Apache's configuration format (tag blocks, etc) and VirtualHosts are a much simpler concept than NGINX's server blocks for people not well-versed in server administration. There is, objectively, a much steeper learning curve for NGINX.

    With Apache, you can simply load the php module in your config, restart the process, and voila, you've got PHP running now. With NGINX, you have to install php-fpm (and configure that, too!), decide whether you want to use socket or port upstream, and configure your server block to only process PHP files. Not to mention the complexity of configuring how requests are sent to your PHP scripts (.htaccess is also much easier in this regard, since there is no reloading of the server config).

    I agree with you that both are capable of being fine-tuned, but out of the box, NGINX is not nearly as safe a bet as Apache is.
  12. HittingSmoke

    HittingSmoke Active Member

    I'd argue XML config is much less user friendly than INI config for non-developers.
  13. brendanc

    brendanc Active Member

    How so? It looks more like HTML and you always know where a block ends because of the named tags? If an NGINX config is poorly written, it can be difficult to tell where one pair of brackets starts and ends.
  14. nemke

    nemke Member

    Writing xml or ini config directives for me it's the same. What's more bigger issue is that Apache has much better documentation and much wider array of examples how to do something. So it is easier to do what you want with Apache.

    P.S. That doesn't mean that Apache is better, in my opinion Nginx at least 100 times better then Apache :)

Share This Page