Discussion:
nginx or apache for php?
(too old to reply)
Walt E
2024-08-01 11:40:01 UTC
Permalink
Hello

I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?

Thank you.
Walt Evans
Andy Smith
2024-08-01 12:00:02 UTC
Permalink
Hi,
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
I do and I don't think it will make any noticeable performance
difference for you, so I would suggest sticking with apache2 unless
you have a stronger need to use nginx or for purely educational
purposes.

Thanks,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting
gene heskett
2024-08-01 13:00:01 UTC
Permalink
Post by Andy Smith
Hi,
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
I do and I don't think it will make any noticeable performance
difference for you, so I would suggest sticking with apache2 unless
you have a stronger need to use nginx or for purely educational
purposes.
Thanks,
Andy
Au contraire Andy. The best, most expandable 3d printer driver, klipper,
uses nginx to build its control interface, apache2 was probably tested
and found wanting. Most of this stuff is run on stm32 for the hardware
interface, administered by klipper running on one of the better pi
clones. rpi3b's generally are minimum but I'm using several 64 bit
bpi-m5's for that.

Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Andy Smith
2024-08-01 13:40:01 UTC
Permalink
Hello,
Post by gene heskett
Au contraire Andy.
What a surprise. Here we go again.
Post by gene heskett
The best, most expandable 3d printer driver, klipper,
uses nginx to build its control interface
It doesn't matter what niche activities you (or I) engage in on niche
hardware that happen to use nginx for reasons you don't know of but
assume are "probably" vital. OP has a working apache2 that they are
familiar with. If they told me they had a working nginx they are
familiar with I'd have told them to stick with that.

I am answering based on OP's stated situation. You are answering
based on your personal circumstances and still making a big leap of
reasoning.
Post by gene heskett
apache2 was probably tested and found wanting.
Fact that it's working for OP's use case trumps your vague
"probably". If OP had come here with a problem we'd solve it, and
that could involve switching to something else. But they didn't.
Post by gene heskett
Most of this stuff is run on stm32 for the hardware interface,
administered by klipper running on one of the better pi clones.
rpi3b's generally are minimum but I'm using several 64 bit
bpi-m5's for that.
It doesn't seem that OP is doing anything like that and if they were
it would be down to them to state they have an issue with
constrained resources. They did not, so your advice is bizarre at
best.

Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting
gene heskett
2024-08-01 17:20:01 UTC
Permalink
Post by José Ángel Pastrana
Hello,
Post by gene heskett
Au contraire Andy.
What a surprise. Here we go again.
Post by gene heskett
The best, most expandable 3d printer driver, klipper,
uses nginx to build its control interface
It doesn't matter what niche activities you (or I) engage in on niche
hardware that happen to use nginx for reasons you don't know of but
assume are "probably" vital. OP has a working apache2 that they are
familiar with. If they told me they had a working nginx they are
familiar with I'd have told them to stick with that.
I am answering based on OP's stated situation. You are answering
based on your personal circumstances and still making a big leap of
reasoning.
Post by gene heskett
apache2 was probably tested and found wanting.
Fact that it's working for OP's use case trumps your vague
"probably". If OP had come here with a problem we'd solve it, and
that could involve switching to something else. But they didn't.
Neither of us has any knowledge of how many coding hours went into
making apach2 work for the OP, the OP didn't indicate.
Post by José Ángel Pastrana
It doesn't seem that OP is doing anything like that and if they were
it would be down to them to state they have an issue with
constrained resources. They did not, so your advice is bizarre at
best.
It also illustrates that this stuff isn't restricted to "genuine rpi"
stuff to run on, there are dozens of other clones that can do this quite
nicely. Some of them quite a bit faster than the rpi's with their usb2
speed limits. That is one of the reasons I chose the bpi-m5, all 4 usb
ports are usb3.

That spreading of "it works for me" info seems like a proper function of
a "community" list, Andy.
Post by José Ángel Pastrana
Andy
Cheers, & best wishes, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Andrew M.A. Cater
2024-08-01 19:10:03 UTC
Permalink
Post by José Ángel Pastrana
Hello,
Post by gene heskett
Au contraire Andy.
What a surprise. Here we go again.
Post by gene heskett
The best, most expandable 3d printer driver, klipper,
uses nginx to build its control interface
I am answering based on OP's stated situation. You are answering
based on your personal circumstances and still making a big leap of
reasoning.
Post by gene heskett
apache2 was probably tested and found wanting.
Fact that it's working for OP's use case trumps your vague
"probably". If OP had come here with a problem we'd solve it, and
that could involve switching to something else. But they didn't.
Neither of us has any knowledge of how many coding hours went into making
apach2 work for the OP, the OP didn't indicate.
There's a to and fro here - none of us knows _exactly_ how much
time and effort the original poster is able to devote to this.
Both would do the job. I used nginx for my Debian mirror because
it allegedly serves small files very well.
It also illustrates that this stuff isn't restricted to "genuine rpi" stuff
to run on, there are dozens of other clones that can do this quite nicely.
Some of them quite a bit faster than the rpi's with their usb2 speed limits.
That is one of the reasons I chose the bpi-m5, all 4 usb ports are usb3.
That spreading of "it works for me" info seems like a proper function of a
"community" list, Andy.
"It works for me" : Gene, how many of your ARM boards are running
Debian as distinct from Ubuntu / Armbian?

You do keep repeating that everyone should follow you in running
ARM boards and pushing stuff forwards yourself but this list always
has problems establishing exactly where your problems lie and exactly
what you've done.

All the very best to all on the list,

Andy
Post by José Ángel Pastrana
Andy
Cheers, & best wishes, Gene Heskett, CET.
--
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
gene heskett
2024-08-02 00:20:01 UTC
Permalink
Post by Andrew M.A. Cater
Post by José Ángel Pastrana
Hello,
Post by gene heskett
Au contraire Andy.
What a surprise. Here we go again.
Post by gene heskett
The best, most expandable 3d printer driver, klipper,
uses nginx to build its control interface
I am answering based on OP's stated situation. You are answering
based on your personal circumstances and still making a big leap of
reasoning.
Post by gene heskett
apache2 was probably tested and found wanting.
Fact that it's working for OP's use case trumps your vague
"probably". If OP had come here with a problem we'd solve it, and
that could involve switching to something else. But they didn't.
Neither of us has any knowledge of how many coding hours went into making
apach2 work for the OP, the OP didn't indicate.
There's a to and fro here - none of us knows _exactly_ how much
time and effort the original poster is able to devote to this.
Both would do the job. I used nginx for my Debian mirror because
it allegedly serves small files very well.
It also illustrates that this stuff isn't restricted to "genuine rpi" stuff
to run on, there are dozens of other clones that can do this quite nicely.
Some of them quite a bit faster than the rpi's with their usb2 speed limits.
That is one of the reasons I chose the bpi-m5, all 4 usb ports are usb3.
That spreading of "it works for me" info seems like a proper function of a
"community" list, Andy.
"It works for me" : Gene, how many of your ARM boards are running
Debian as distinct from Ubuntu / Armbian?
Round about, all of them are running armbian, which, depending on the
individual install, is either running debian bookworm for arm64, in the
server version, or jammie in the full desktop installs. In either event,
the actual dl I installed came from the armbian site. Either way, it
just works on the arm64's.
Post by Andrew M.A. Cater
You do keep repeating that everyone should follow you in running
ARM boards and pushing stuff forwards yourself but this list always
has problems establishing exactly where your problems lie and exactly
what you've done.
Why should I try anymore? Everytime I try to describe what I've done, I
get called a liar. That gets old rather quickly.

What I will do, when trxie is released, is install it, but you will get
to read absolutely everything I had to do to make it work.
Post by Andrew M.A. Cater
All the very best to all on the list,
Ditto Andy.
Post by Andrew M.A. Cater
Andy
Post by José Ángel Pastrana
Andy
Cheers, & best wishes, Gene Heskett, CET.
--
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
.
Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Stanislav Vlasov
2024-08-01 12:10:02 UTC
Permalink
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
If your setup works fine, use apache2 as php runner.
Nginx needs config exercises for .htaccess replacements and this is
sometimes too complicated for beginners.
For performance on multiple slow clients add nginx as reverse proxy
(as most other hosting setups), or use apache proxy module (never seen
last ~15 years).

Nginx is faster than apache2 because it get all data from backend,
send it to a slow client and backend ready to new request while nginx
sending data.
Apache2 can do it with proxy module, but i was see such configuration
around 2006, nginx as reverse proxy easier to configure.
--
Stanislav
Dan Ritter
2024-08-01 13:00:01 UTC
Permalink
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
I have experience on both.

Do you have a performance problem? If not, don't change.

If you do have a performance problem: how much have you
optimized already? What methods have you used? Can you define
the gap between what you have and what you need?

How much is it worth to you in terms of time, and in terms of
money?

-dsr-
Alain D D Williams
2024-08-01 14:00:03 UTC
Permalink
Post by Dan Ritter
Do you have a performance problem? If not, don't change.
More to the point - what does the application do, where does its time go ?
Eg if you have complex database selects then the web server overhead prolly
only takes a small part of total time -- so changing it will gain you little.

You need to profile & understand first.
Post by Dan Ritter
If you do have a performance problem: how much have you
optimized already? What methods have you used? Can you define
the gap between what you have and what you need?
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 https://www.phcomp.co.uk/
Parliament Hill Computers. Registration Information: https://www.phcomp.co.uk/Contact.html
#include <std_disclaimer.h>
Andy Smith
2024-08-01 14:20:01 UTC
Permalink
Hello,
Post by Alain D D Williams
You need to profile & understand first.
It really seems more like a case of Fear Of Missing Out - "some
people said nginx is faster". 😀

I'm all for a fun learning experience, but I don't think OP is
particularly missing out otherwise.

Thanks,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting
Nicholas Geovanis
2024-08-02 00:40:01 UTC
Permalink
Post by Dan Ritter
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
I have experience on both.
Do you have a performance problem? If not, don't change.
If you do have a performance problem: how much have you
optimized already? What methods have you used? Can you define
the gap between what you have and what you need?
How much is it worth to you in terms of time, and in terms of
money?
All good points which reinforce the idea that the only benchmark that
really matters is the benchmark of your specific application.

I was only once in a situation where I had nginx and apache serving the
same content from the same server. I could start whichever I wanted. Nginx
was clearly faster -for that content-. It was a simple web application,
retrieving content from a few-gig local MySQL database. YMMV.

-dsr-
José Ángel Pastrana
2024-08-01 13:10:01 UTC
Permalink
Post by Walt E
Hello
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
Thank you.
Walt Evans
Hello,

by default, Apache uses mod_php versus Nginx uses php-fpm. A lot of
people credit to nginx a better performance, but it should be credited
to php-fpm really!

Apache has three types of multi-processing modules (MPM) to handle
incoming requests: prefork (legacy, <2.4), worker (newer, >=2.4) and
event (newest, >=2.4).

- Prefork implements a non-threaded, pre-forking web server
- Worker implements a hybrid multi-threaded multi-process web server
- Event is a variant of worker implementation consuming threads only for
connections with active processing

Most Linux distributions configure prefork module by default, impacting
about the real PHP performance. The reason is stability and
compatibility along with some modules requiring legacy support like
mod_php which **only** works under a process-per-request model (prefork)
[1].

If you need mod_php in your Apache instance, then you cannot benefit
from using a threaded multi-processing model (worker or event).

You can find some performance tests between prefork, worker and event
modules for Apache doing a quick search, getting better performance both
worker and event modules versus prefork module.

In order to get PHP under a threaded multi-processing model (worker or
event) and serve pages quicker than just using mod_php module (with
only-compatible prefork model), get rid mod_php module and migrate to
php-fpm service + mod_fcgid module + mpm_event.

Then, only then, you may start thinking an apache versus nginx fair battle.

Talking about my personal experience in PHP projects, I do not see a big
difference to say a clear winner.

Regards.

[1]
https://www.php.net/manual/en/faq.installation.php#faq.installation.apache2
José Ángel Pastrana
2024-08-01 13:30:02 UTC
Permalink
Post by Walt E
Hello
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
Thank you.
Walt Evans
Hello,

**by default**, Apache uses mod_php versus Nginx uses php-fpm. A lot of
people credit to nginx a better performance, but it should be credited
to php-fpm really!

Apache has three types of multi-processing modules (MPM) to handle
incoming requests: prefork (legacy, <2.4), worker (newer, >=2.4) and
event (newest, >=2.4).

- Prefork implements a non-threaded, pre-forking web server
- Worker implements a hybrid multi-threaded multi-process web server
- Event is a variant of worker implementation consuming threads only for
connections with active processing

Most Linux distributions configure prefork module by default, impacting
about the real PHP performance. The reason is stability and
compatibility along with some modules requiring legacy support like
mod_php which **only** works under a process-per-request model (prefork)
[1].

If you need mod_php in your Apache instance, then you cannot benefit
from using a threaded multi-processing model (worker or event).

You can find some performance tests between prefork, worker and event
modules for Apache doing a quick search, getting better performance both
worker and event modules versus prefork module.

In order to get PHP under a threaded multi-processing model (worker or
event) and serve pages quicker than just using mod_php module (with
only-compatible prefork model), get rid mod_php module and migrate to
php-fpm service + mod_fcgid module + mpm_event.

Then, only then, you may start thinking an apache versus nginx fair battle.

Regards.

[1]
https://www.php.net/manual/en/faq.installation.php#faq.installation.apache2
Sarunas Burdulis
2024-08-01 14:40:01 UTC
Permalink
Hello
I have been using apache2 + php for years under debian. But I heard
people says nginx + php has better performance.
That is not true:

1. https://people.apache.org/~jim/presos/ACNA11/Apache_httpd_cloud.pdf
2.
https://www.slideshare.net/slideshow/choosing-a-proxy-server-apachecon-2014/33506168

--
Sarunas Burdulis
Dartmouth Mathematics
math.dartmouth.edu/~sarunas

· https://useplaintext.email ·
gene heskett
2024-08-01 17:30:01 UTC
Permalink
Post by Sarunas Burdulis
Hello
I have been using apache2 + php for years under debian. But I heard
people says nginx + php has better performance.
1. https://people.apache.org/~jim/presos/ACNA11/Apache_httpd_cloud.pdf
2.
https://www.slideshare.net/slideshow/choosing-a-proxy-server-apachecon-2014/33506168
While (2) purports to be all encompassing, I'll point out that the data
is a decade stale. And needs redone using contemporary tooling.

Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Jeffrey Walton
2024-08-01 15:30:01 UTC
Permalink
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
Related, Nginx is generally considered more secure than Apache. Nginx
has approximately 220 CVEs, while Apache and friends has roughly 2700
CVEs. Confer, <https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=apache>
and <https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=nginx>.

I think it was Jon Bentley who said, if it does not have to be
correct, then I can make it as fast as you want it to be. Quickly
arriving at an incorrect result is not a good outcome.

Jeff
Walt E
2024-08-01 20:10:02 UTC
Permalink
Hello

I am currently running a simple Wordpress service with low traffic, so I
have not encountered any performance issues. Apache performs well. But I
will still try nginx+php fpm as a substitute when I have time. As for
reverse proxy, because I used CloudFlare, I think CloudFlare's web
server plays the role of reverse proxy here. And as far as I know, CF
also uses nginx.

Thanks for all your help.
Post by Jeffrey Walton
Post by Walt E
I have been using apache2 + php for years under debian.
But I heard people says nginx + php has better performance.
Do you have experience on both of setup and share a bit with me?
Related, Nginx is generally considered more secure than Apache. Nginx
has approximately 220 CVEs, while Apache and friends has roughly 2700
CVEs. Confer, <https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=apache>
and <https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=nginx>.
I think it was Jon Bentley who said, if it does not have to be
correct, then I can make it as fast as you want it to be. Quickly
arriving at an incorrect result is not a good outcome.
Jeff
Loading...