Forum

php files get downloaded instead of sent to php-fpm/php-fcgi

Sil68
24 September 2012, 06:34


Hiawatha version: 8.5
Operating System: MacOS X 10.8.2

I'm in the process of migrating away from apache to an alternative; currently I'm looking at nginx, resin, cherokee and hiawatha.

At the moment I'm struggling getting hiawatha the serve php (or any other similar ones) files via the fastcgi backend connection, which unfortunately get only downloaded instead of processed by the fastcgi setup.
Hugo Leisink
24 September 2012, 18:40
I need some more information than only a message that it isn't working. The "CGI and FastCGI" howto page gives you all the information you need to get PHP started.
Sil68
24 September 2012, 19:20
I've proceeded according to the HowTo, but still...

My hiawatha.conf
##########
## GENERAL SETTINGS
ServerId = www:www
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log

##########
## BINDING SETTINGS
## A binding is where a client can connect to.
Binding {
#BindingId = lo0
Port = 80
#Interface = 127.0.0.1
#Interface = 0.0.0.0
MaxKeepAlive = 30
TimeForRequest = 3,20
}

##########
## COMMON GATEWAY INTERFACE (CGI) SETTINGS
## These settings can be used to run CGI applications. Use the 'php-fcgi'
## tool to start PHP as a FastCGI daemon.
FastCGIserver {
FastCGIid = php-fpm
ConnectTo = /var/run/php/php-fpm.sock
Extension = php
}

##########
## URL TOOLKIT
## This URL toolkit rule was made for the Banshee PHP framework, which
## can be downloaded from http://www.hiawatha-webserver.org/banshee
UrlToolkit {
ToolkitID = banshee
RequestURI isfile Return
Match ^/(css|files|images|js|slimstat)($|/) Return
Match ^/(favicon.ico|robots.txt|sitemap.xml)$ Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}

##########
## DEFAULT WEBSITE
## It is wise to use your IP address as the hostname of the default website
## and give it a blank webpage. By doing so, automated webscanners won't find
## your possible vulnerable website.
Hostname = 127.0.0.1

WebsiteRoot = /usr/local/var/www/hiawatha
AccessLogfile = /var/log/hiawatha/default-access.log
ErrorLogfile = /var/log/hiawatha/default-error.log

StartFile = index.html
#ErrorHandler = 404:/error.cgi

#TimeForCGI = 5
UseFastCGI = php-fcgi
UseToolkit = banshee

PreventCSRF = yes
PreventSQLi = yes
PreventXSS = yes

Alias /icons:/Volumes/MHData/Web/icons
Alias /images:/Volumes/MHData/Web/images

Alias /download:/Volumes/MHData/Web/download
Alias /upload:/Volumes/MHData/Web/upload

Alias /apps:/Volumes/MHData/Web/apps
Alias /tools:/Volumes/MHData/Web/tools

##########
## VIRTUAL HOSTS
## Use a VirtualHost section to declare the websites you want to host.
VirtualHost {
Hostname = my.host.net, 192.168.5.100
#RequiredBinding = en0

WebsiteRoot = /Volumes/MHData/Web/sites/my.host.net
AccessLogfile = /var/log/hiawatha/my.host.net-access.log
ErrorLogfile = /var/log/hiawatha/my.host.net-error.log

StartFile = index.html
}


My php-fcgi.conf
## Path to PID-file.
## PidFile = <filename>
PidFile = /var/run/php/php-fpm.pid

## Number of maximum requests per fork before respawning.
## MaxRequests = <number>
MaxRequests = 100

## PHP FastCGI servers to start.
## Server = <php-cgi executable>;<forks>;<binding>;<UID>[:<GIDs>][;<PHP configuration file>]
Server = /usr/local/sbin/php-fpm ; 3 ; /var/run/php/php-fpm.sock ; www:www ; /usr/local/etc/php/5.4/php.ini
Hugo Leisink
24 September 2012, 21:09
In php-fcgi.conf, you try to start php-fpm. php-fpm is what php-fcgi also is for: to start PHP as a FastCGI daemon. You should change it to php-cgi.
Sil86
24 September 2012, 21:43
I've had a discussion just recently in regards to 'php-cgi', and I've been informed that 'php-cgi' is way outdated and 'php-fpm' is supposed to be used instead (this one, allegedly is a special version of php itself, and not executing php-cgi, and much more stable and of a high performance than php-cgi), that's why I've placed 'php-fpm' in here instead of 'php-cgi'; anyways, I'll give it a shot...
Hugo Leisink
25 September 2012, 01:06
That's not true. php-fpm is just php-cgi that comes with some extra stuff to run it as a FastCGI daemon. php-cgi works just fine. However, php-fpm is far more advanced than Hiawatha's php-fcgi. I advice you to use php-fpm. I'm using it too. I'm planning to make php-fcgi deprecated soon and in the near future remove it from the Hiawatha package.
Sil68
25 September 2012, 06:26
Okay, I see...

I've now tried all three options: a) php-fpm; b) php-fcgi; and c) php-cgi, but it was to no avail! The php files always got downloaded instead of being processed.

There must be something wrong with my configuration....

I've compiled hiawatha with the toolkit support, do I have to install Banshee additionally? Where to?
Hugo Leisink
25 September 2012, 08:08
Have you read the CGI and FastCGI howto page? The UseFastCGI must by inside the VirtualHost section. Read the manual page to see what settings are 'global' and which are for '(virtual) hosts'.
This topic has been closed.