php-fpm tutorial done: heavily-tested & seamless
-
hey all,
Happy April Fool's, but nonetheless this post content is for real!
so Drupal is checked off the list adn this week I'd planned to start the permissions series. I got waylaid ..
one or two folks were having "502 Bad Gateway" issues with the fastCGI tut (fixed an issue there thanks to Haynes .. tx m8, appreciated.) I've updated the original PHP/MySQL for Nginx tut:-
.. to allow for this possible error.
But. This problem forced my hand as well, to do something I've been wanting to for a while now ..
.. there have been a lot of requests, not just here but previously at Guvnr, for an alternative to the standard php-fastCGI guide above, using php-fpm.
When I originally wrote the Bible I discounted php-fpm because, at that time, it hadn't been maintained in something like a year.
.. but a few months back it sprang back into life and, not only that, PHP is taking the code into its core.
Coupled with the fact that it has benchmarked impressively against the fastCGI method I've been playing around with various methods of installing php-fpm, publishing yesterday what I consider to be the best of those. Tested on fresh servers for Debian and Ubuntu builds:-
Compile PHP-FPM (PHP5) & MySQL for Nginx
This changes the order of documentation for the Nginx-VPS setup guide so I'm now reworking docs and the index order accordingly and will be adding a special PHP index page listing the 2 current php installation options, as well as the forking tutorials written/underway/planned to explain and help you choose your preferred install procedure. It will be pretty self-explanatory.
I'll add a link to that php index page in this forum.
When this PHP detour is done I'll get back to that permissions series .. sorry for any inconvenience but, for anyone wanting php-fpm, I know for a fact (as does my Google search history!) that you won't find a better guide anywhere - and none that 'just work'.
Posted 2 years ago # -
so is php-fpm better than fcgi? where did you find benchmarks?
Posted 2 years ago # -
hey osb .. truth is I don't know!
.. i intend to find out though.
i do know a lot of folks have been raving about fpm. have seen 2/3 old benchmarks, can't remember where except for on this excellent guide (or was, it's 2 years old now and breaks with php5)
http://www.yawn.it/2008/04/30/nginx-php-php-fpm-on-debian-etch-40/
basically, that says:-
Benchmark on a 256mb xen vps:
apache2+mod_php+xcache = 42 req/sec
nginx+xcache+php-fpm = 150 req/sechopefully i'll be benchmarking this week on otherwise identical Linode 360s.
Posted 2 years ago # -
Hey Guv, just doing a fresh install, noticed your command to add to the end of the php.ini file
magic_quotes_gpc=0
however I found the following in my default ~/php-5.3.0/php.ini which looks like it would conflict
; Magic quotes are a preprocessing feature of PHP where PHP will attempt to
; escape any character sequences in GET, POST, COOKIE and ENV data which might
; otherwise corrupt data being placed in resources such as databases before
; making that data available to you. Because of character encoding issues and
; non-standard SQL implementations across many databases, it's not currently
; possible for this feature to be 100% accurate. PHP's default behavior is to
; enable the feature. We strongly recommend you use the escaping mechanisms
; designed specifically for the database your using instead of relying on this
; feature. Also note, this feature has been deprecated as of PHP 5.3.0 and is
; scheduled for removal in PHP 6.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/magic-quotes-gpc
magic_quotes_gpc = OffPosted 2 years ago # -
This command:
update-rc.d php-fpm defaults; invoke-rc.d php-fpm startI found that the following worked better:
update-rc.d php-fpm defaults; invoke-rc.d php-fpm start
Posted 2 years ago # -
This command:
cp php.ini-production /etc/php/php.iniI used:
cp ~/php-5.3.0/php.ini-production /etc/php/php.iniwhich worked better due to opening a second window rather than waiting for the test to complete
Posted 2 years ago # -
I've followed the guide through from scratch, but avoided the " PHP5, MySQL and Xcache (for Platforms like WordPress)" step in favour of the php-fpm version.
Pretty sure PHP is missing some required components now though, such as php5-mysql
[quote]dpkg -l | grep php
ii libapache2-mod-php5 5.2.4-2ubuntu5.10 server-side, HTML-embedded scripting languag
ii php5-common 5.2.4-2ubuntu5.10 Common files for packages built from the php
ii php5-gd 5.2.4-2ubuntu5.10 GD module for php5
ii php5-mcrypt 5.2.3-0ubuntu1 MCrypt module for php5
ii php5-mysql 5.2.4-2ubuntu5.10 MySQL module for php5
ii phpmyadmin 4:2.11.3-1ubuntu1.3 Administrate MySQL over the WWW[/quote]can I install missing components with
[quote]sudo aptitude -y install php5-cgi php5-mysql php5-xcache php5-common php5-dev php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-mcrypt php5-curl php5-gd php5-memcache php5-mhash php5-pspell php5-snmp libmagick9-dev php5-cli php5-xcache[/quote]
Also, the postfix interactive test doesn't send mail, in fact the exit (); command has no effect and I have to ctrl-c to get out.
Posted 2 years ago # -
so I installed them, and now I'm back to the old
"Your PHP installation appears to be missing the MySQL extension which is required by WordPress."
and phpmyadmin has a message in the footer
"Cannot load mysql extension. Please check your PHP configuration. - Documentation"
Posted 2 years ago # -
mo .. apologies, hadn't tested MySQL with the php-fpm setup and it wasn't working.
tutorial changed y'day, now tested to work with MySQL!
Posted 2 years ago # -
Guv,
Thanks very much.Two things I am absolutely crazy to know:
- How can I change the PHP configuration, once I have everything installed? Would a simple remove php solve the matter? If it does, will I have to pass trough all the installation procedures again from the start (installing PHP Package Compilers etc)?
- How can I add modules for beeing installed? Is there a place where I can see all the modules list that is being installed in order I can make a selection?Posted 2 years ago # -
I think I found out: http://packages.debian.org/source/sid/php5
Posted 2 years ago # -
Does anybody know how I can mix this two tutorial in only one procedure? (PHP5+Xcache) http://vpsbible.com/php/speed-up-vps-config-php-xcache/ and (PHP5+PHP-FPM) http://vpsbible.com/php/compile-install-php-fpm-mysql-nginx/
Posted 2 years ago # -
hey atipico,
sorry, I know the documents are a bit strewn about at the moment .. I'll be adding a PHP Index page to help you work your way about and make whatever choices.
basically, to answer your last few posts:-
- to remove the originally installed php modules, use:-
sudo aptitude purge [php-list]
then to reinstall using php-fpm? follow this:-
http://vpsbible.com/php/compile-install-php-fpm-mysql-nginx/
then for Xcache (and yes you could carry out this tutorial at the end of the previous one, while php.ini is already open, but either way .. ):-
http://vpsbible.com/php/speed-up-vps-config-php-xcache/
.. you should do the Suhosin PHP patch tutorial too.
Posted 2 years ago # -
and for anyone who wants to reinstall a compiled php installation, with no downtime, i just published this:-
Posted 2 years ago # -
Super ultra über. Precise and direct. Thank you very much! Just one more question.
Let's say we notice there's a missing module, Tidy for example. How can we add it to the installation "lot"? And after, in the case we have already installed everything, how can we add it later?
Posted 2 years ago # -
If I got it correctly, once we compile php the way you are teaching us, for every new module we need to install, we must to do it all again: recompiling php with the new modules along with all the previous ones. Is it so?
Posted 2 years ago # -
People, many doubts about how to compile a software are answered here: http://www.ibm.com/developerworks/aix/library/au-speakingunix12/
Posted 2 years ago # -
Hi atapico, yes, you'd have to recompile. Once you know what module you want though, this is a matter of a few minutes.
Posted 2 years ago #
Reply
You must log in to post.
Want HTML?
a blockquote code em strong ul ol liPlace code between backticks `codeHere`
You've got it.
