Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vipin93's avatar

Nginx vs Apache2 which server best for Laravel

Recently I buy Cloud hosting and I confused weather I should install nginx or apache can any one clear me which one should I install

0 likes
10 replies
bashy's avatar

Well, there's no clear choice but it's down to what you prefer or can manage. Nginx has a different way of passing PHP requests to PHP itself, compared to Apache. Anything like redirects or rewrites (SEO) will be different.

Both are supported, both will work just fine but you may want to choose either or depending on what you want to do. Apache has more features but Nginx has a fast static file serving speed.

2 likes
uxweb's avatar

I used to use Apache 2, but, since i learned that PHP-FPM and nginx works better for performance i decided use nginx.

Other reasons why i like nginx are:

  • Configuration is easier to learn and less verbose
  • Serves static files more efficiently
  • No need for .htaccess files

;)

3 likes
vipin93's avatar

@bashy in my app basically have more images and less content so may i choose Nginx?

bashy's avatar

@uxweb Most of the time Apache will be used as a back end for Nginx (to serve PHP files) while Nginx will be used to serve static files. Apache is faster in some cases, there's even some new modules that have come out to make it faster than it is now.

@vipin93 You can choose either. Have you used Nginx with PHP-FPM before? Do you have anything that you need to configure for your website(s), like redirects or cache/load balancing?

uxweb's avatar

You can take a look at www.serversforhacekers.com or get the servers for hackers book at https://leanpub.com/serversforhackers/.

Chris Fidao explains very well Apache, Nginx, PHP and PHP-FPM.

With this information you can take a more convenient/informed decision for your case.

1 like
bashy's avatar

@vipin93 Then it's really down to which one you know well or willing to learn (if needed). Either will work just fine.

Personally, I use Nginx since I prefer it and I know it well. I like the syntax of vhosts and also the stuff you can do inside a server block.

vipin93's avatar

@bashy I'm not the expert guy in web I'm beginner, I just start learning so I should use Nginx ?

tuDEV's avatar

if one were already hosting an app on apache2, is it easy to migrate over to nginx? (i have never used nginx ever in my life, but want to try it out)

1 like

Please or to participate in this conversation.