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

TomCawthorn's avatar

Why is Laravel defaulted to Nginx?

Homestead and Forge will install and serve with Nginx - but from what I've read, Nginx is better at serving static pages than Apache.

I realise as I write this that the write ups don't specifically say that Nginx is a lot worse at serving dynamic content than Apache.. but it seems that Apache would be more suited for a dynamic php environment?

Maybe this is a "1 million users problem" - in other words, if you get to a point where you're splitting hairs between the two, it's a good problem to have!

0 likes
5 replies
uxweb's avatar

HI, @TomCawthorn, I think both servers are good, but i prefer Nginx because of its more efficient architecture, the less verbose configuration it lets you do and the performance.

Nginx with php will work as a proxy, because Nginx can't process php code itself, so it will pass the request made to a php file to the php-fpm cgi gateway.

The same is for the new Apache.

If you use the old Apache way that let's apache process a php file request using an Apache "module", then there will be a performance problem with a 1 million users.

This is my opinion based on many time using apache and now joying using Nginx.

Also, i have learned a lot of this stuff from @fideloper and his great book ServersForHackers.

Hope this helps you!

3 likes
Penderis's avatar

Because taylor build everything with nginx backends I would think.

1 like
constb's avatar
constb
Best Answer
Level 6

@TomCawthorn actually nginx is a very good mutipurpose web server. nginx+php-fpm works just as perfect as a good old apache+mod_php.

The only real reason why you still may want apache is if your application relies on .htaccesses or if you're hosting multiple sites and .htaccess is a requirement for some of them. Even then I'd still put apache behind nginx reverse proxy.

You see, apache uses threads and a thread gets blocked both while php script processes data and while it sends it to client. Nginx reverse proxy quickly sucks in the response from apache and frees its thread for the next request. And if client slowly read the data that's all handled by nginx. And nginx's architecture allows it to have like endless amount of connections at once without any performance issues.

3 likes
bashy's avatar

Laravel was not built for one particular web server... Nginx is easy to use, just route everything through the index.php file. Apache is setup via the .htaccess file in Laravel /public/ folder.

Maybe Nginx was used on Homestead/Forge because of choice and ease of use within the Forge system. Nginx is also climbing high in the web server world use chart.

2 likes
TomCawthorn's avatar

Hi all! Thanks for filling me in :-)

I know that Laravel isn't built for one server in mind, it just surprised me that nginx was (what I would consider a 'default') because it's the basic set up for both homestead and forge.

Either way, I have learned something new so yay!

Thanks

Please or to participate in this conversation.