Are Nginx, MariaDB, PHP-FPM worth the effort?
I'm going to spin up a new Linode using Ubuntu 22.04 since 20.04 is winding down in support.
I've been reading about the Nginx, MariaDB, and PHP-FPM so-called 'advantages' over Apache, MySQL, and PHP-mod (with Apache)
All I have are a few WordPress sites and a few static Bootstrap sits, none of which get more than 20 'legitimate' hits a day… often less (i.e. not counting bots or crawlers or hack attempts).
I have a large Piwigo photo site that gets maybe 20 legit hits a MONTH.
I have a very important EspoCRM database that I use daily, but no one else does.
I know how to install/configure a plain old LAMP stack although I've not done it for about three years.
Considering the low volumes is there any reason in your opinion to embark on the ***learning curve for Nginx, MariaDB, PHP-FPM and install and configure that stack instead?
(***You have to be a Ph.D. in quantum physics to figure out how to do a simple 301 Redirect in Nginx since there is no .htaccess facility.)
12 Replies
I've been reading about the Nginx, MariaDB, and PHP-FPM so-called 'advantages' over Apache, MySQL, and PHP-mod (with Apache)
- MariaDB is a drop-in replacement for MySQL…so that's a wash (at least for running Wordpress and stuff like that).
- php-fpm is your only choice with nginx -- there is no mod_php for nginx (mod_php is part of php…not apache2…and the php folks want mod_php to go away).
- nginx is a capable-enough web server. However, it is not the be-all/end-all. It has some advantages (it's natively multi-threaded) but the configuration model is very different from apache2. There is also not the infrastructure on Linux for apache2 (a2{en, dis}{mod, conf,site}).
My recommendation:
- Keep apache2…but use a multi-threaded MPM (mpm_event or mpm_worker). It's familiar and it will perform well with a low footprint.
- Dump mod_php in favor php-fpm. Going to a multi-threaded MPM will force you to dump mod_php anyway.
- Use MariaDB or MySQL as you wish. For you, they're probably interchangeable.
The learning curve vs. that of switching to nginx will be much smaller.
-- sw
Keep apache2…but use a multi-threaded MPM (mpm_event or mpm_worker).
Do you mean FPM and not MPM?
I upgraded to FPM on my current server and on my small websites I didn't notice any speed increases vs the mod_php. But as I understand it, on a brand new install, installing FPM is not harder than installing whatever non-FPM is.
I'll take your advise and stay with mySQL and Apache2.
Thanks.
No…MPM…multi-processing module.
There are 3 on *nix:
- mpm_prefork — spawns processes to handle requests.
- mpm_worker & mpm_event — spawn threads to handle requests (using different thread-management strategies).
There are a couple of others but they're obsolete: mpm_netware & mpm_os2. apache2 has an API for MPMs so, if you feel so inclined, you can write your own.
mod_php, because it is not thread-safe, will only work with mpm_prefork.
php-fpm moves the PHP interpreter to it’s own (multi-threaded) process so it will work with any MPM.
I didn't notice any speed increases vs the mod_php.
You should try increasing the size of the thread pool for php-fpm: https://luminaconsultancy.com/server-tuning-php-fpm/
Change 7.3 in the article to whatever your PHP version is.
I use mpm_event.
See: https://tecadmin.net/apache-mpm-prefork-and-worker-and-event/
— sw
OK, I'll do as you suggest. One thing… every "how to install FPM" website has different parms for php.ini.
Here is one set:
https://www.cloudbooklet.com/how-to-install-php-fpm-with-apache-on-ubuntu-22-04/
upload_max_filesize = 32M
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000
Here is what I use, but not sure why!!
max_execution_time = 180
max_input_time = 180
memory_limit = 256M
post_max_size = 50M
upload_max_filesize = 50M
Is there some recognized standard setting for FPM?
No…php-fpm uses the same php.ini as everything else.
php-fpm server parameters are kept in php-fpm.conf & php-fpm.d/poolname.conf…where poolname is the name of the thread pool the configuration is for.
No…php-fpm uses the same php.ini as everything else.
Well, there is a php.ini file in /etc/php/8.0/fpm which is where I made my changes (in previous post.) Isn't that the correct .ini for FPM?
Well, there is a php.ini file in /etc/php/8.0/fpm which is where I made my changes (in previous post.) Isn't that the correct .ini for FPM?
Yes, you're right. One global php.ini for mod_php, the CLI and php-fpm seems to be a BSD-ism. Sorry for the confusion…
-- sw
Yes, you're right.
Wow. I never thought I'd see the day when I was right and you were wrong. How can that be? Maybe in a parallel universe somewhere, but not in this one!!!
I'm buying a lottery ticket this afternoon!!
I have been down this road many times and in the end began using an expert in NGINX for admin assistance. I can post his contact info if you want, he is in the Ukraine so I don't know if Russia has terminated his processes yet.
However, because of this I moved away from that and went to Litespeed. It too has a learning curve but it was one I was more easily able to master. I use the commercial version and am overall happy with it.
went to Litespeed
The commercial version is too expensive for me.
I'm interested in the Open Source version.
Did you install it via their .sh script to add the LSWS repo and then via 'apt'?
Is Litespeed Open any better than Apace2 for low volume static sites?
OpenLitespeed is the one that tried to FUD their way into bigger market share vis-à-vis apache2 using HTTP/3 (not yet a standard) as marketing hype:
https://www.litespeedtech.com/http3-solutions
Apparently, OLS has had some problems with security vulnerabilities lately:
https://borncity.com/win/2022/11/20/openlitespeed-vulnerabilities-put-web-server-at-risk/
-- sw
OLS has had some problems
I had never heard of OLS before. I knew about their commercial offering but didn't know they had an open source version.
I'll stick with what I know… plain old LAMP(fpm).
I wonder if I'll notice any speed difference on a dedicated server vs a VPS? I have no idea what the normal load is on whatever server my domains are placed on now.