Forum

Hiawatha and PHP-FPM

Olli
2 July 2010, 23:49
Hi everybody,

I'm relatively new to Hiawatha and server configuration itself so my question might be a stupid one: I use the newest PHP version (5.3.2) and PHP-FPM and want to know how to configure Hiawatha the right way to use fpm instead of cgi.

I changed the following line in the main config:
CGIhandler = /usr/bin/php5-fpm:php,php5

And uncommented the following one in php-fcgi.conf:
Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data ; /etc/php5/fpm/php.ini

A php file with phpinfo in it is interpreted (u can check at http://178.63.170.13) so it seems to run. But did I change the right thing(s)?

Kudos,
Olli

--
Hiawatha version: 7.3
Operating System: Debian 5
Hugo Leisink
3 July 2010, 00:18
I have no experience with php-fpm, so I can't tell for sure. According to the online documentation, php5-fpm is only a replacement for the original FastCGI implementation in PHP5. So, you can safely replace php5-cgi with php5-fpm.

Using php5-fpm with the CGIhandler is not going to help. CGIhandler is to use PHP5 in normal CGI mode, not in FastCGI mode.

Exchange php5-cgi with php5-fpm in php-fcgi.conf and use the FastCGI settings in hiawatha.conf as described in the CGI and FastCGI HOWTO page.

Oh, and remember: questions are never stupid.
Olli
3 July 2010, 09:48
Unfortunately that doesn't work for me - I get a "503 - Service unavaiable" error while trying to open some php document. My hiawatha.conf looks like this:
ServerId = www-data
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log

Binding {
Port = 80
MaxKeepAlive = 30
TimeForRequest = 3,20
}

BanOnGarbage = 300
BanOnMaxPerIP = 60
BanOnMaxReqSize = 300
KickOnBan = yes
RebanDuringBan = yes

CGIhandler = /usr/bin/perl:pl
CGIhandler = /usr/bin/php5-cgi:php,php5
CGIhandler = /usr/bin/python:py
CGIhandler = /usr/bin/ruby:rb
CGIhandler = /usr/bin/ssi-cgi:shtml
CGIextension = cgi

FastCGIserver {
FastCGIid = PHP5
ConnectTo = 127.0.0.1:2005
Extension = php, php5
SessionTimeout = 30
}

Hostname = 127.0.0.1
WebsiteRoot = /var/www/public
StartFile = index.php
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
TimeForCGI = 5
UseFastCGI = PHP5

And the content of the php-fcgi.conf:
PidFile = /var/run/php-fcgi.pid
Forks = 3
MaxRequests = 100
Server = /usr/bin/php5-fpm ; 127.0.0.1:2005 ; www-data ; /etc/php5/fpm/php.ini

Btw: PHP-FPM comes with a daemon which is running in /etc/init.d plus a PID file in /var/run. Maybe it isn't even necessary to create the php-fcgi.pid file and one can rather utilize the present file?

Kudos,
Olli
Hugo Leisink
3 July 2010, 10:43
If PHP-FPM comes with an init.d script, perhaps you don't need php-fcgi at all. Try to find out what that init.d script does (at which port it makes PHP running). Use that port in your hiawatha.conf file.
Olli
3 July 2010, 14:11
Alright, port 9000 did the trick, thank you! A last question: When I stop the daemon (php-fcgi -k -c /etc/hiawatha/php-fcgi.conf) PHP still runs fine. Since Hiawatha created a php-fcgi in /etc/init.d, the daemon runs after every reboot. Is it safe to just remove the php-fcgi from /etc/init.d?

Kudos,
Olli

P.S.: Keep up the good work with Hiawatha. My first intention when I got my new vserver was to use Cherokee, but I found Hiawatha by accident and will never use another webserver! What a pity that this great piece of software isn't known better.
Hugo Leisink
3 July 2010, 16:59
You can remove the script from /etc/init.d, but that's not the best way to do it. The scripts in /etc/init.d are called via softlinks in /etc/rc*.d. Remove the softlink in the right /etc/rd?.d directory. The best way to do that is via the rcconf tool (can be found in the rcconf package). Google for 'linux runlevels' to know more about the /etc/init.d and /etc/rc*.d directories.

About Hiawatha not being very known: you can help! Spread the word, please.
This topic has been closed.