Forum

phpfpm and fastcgi with C application on one host

Carsten
25 November 2013, 12:41
Dear Hugo,

thank you for this clean and well documented software. Excellent!
I'm using Hiawatha with phpfpm on my embedded system to serve HTML content with PHP for a GUI. This works great.

Additionally, I want to serve RESTful HTTP requests on the same target, by using FastCGI with a C application, because of performance needs (PHP is no-go).
My intention is to access the GUI at e.g. 192.168.1.0/gui/ and the RESTful API at 192.168.1.0/api/ on the target.
Having an embedded system, I don't use virtual hosts. Here is an excerpt of my hiawatha.conf file:
Binding {
Port = 80
Interface = 0.0.0.0
}

FastCGIserver {
FastCGIid = phpfpm
ConnectTo = 127.0.0.1:9000
Extension = php
}

UrlToolkit {
Match ^/gui/.*\?(.*) Rewrite /gui/index.php?$1
Match ^/gui/.* Rewrite /gui/index.php
Match ^/.* Rewrite /index.html
}

Hostname = 127.0.0.1
WebsiteRoot = /usr/local/var/www/data
UseFastCGI = phpfpm

This works fine, even if the IP address of the interface is reconfigured manually or by DHCP.

But how to handle phpfpm / PHP and fastcgi / C application in parallel on the host, with the request URIs as mentioned before?

Any help is kindly appreciated.

Thanks,
Carsten

Hiawatha version: 9.2
Operating System: ARM, Linux
Hugo Leisink
25 November 2013, 12:56
It must be something like the following config. Please note that I haven't tested it myself.

Binding {
Port = 80
Interface = 0.0.0.0
}

FastCGIserver {
FastCGIid = phpfpm
ConnectTo = 127.0.0.1:9000
Extension = php
}

FastCGIserver {
FastCGIid = apifcgi
ConnectTo = 127.0.0.1:<API port>
}

UrlToolkit {
ToolkitID = my_toolkit
Match ^/gui/ UseFastCGI phpfpm
Match ^/api/ UseFastCGI apifcgi
}

Directory {
Path = /usr/local/var/www/data/gui
StartFile = index.php
}

Hostname = 127.0.0.1
WebsiteRoot = /usr/local/var/www/data
UseToolkit = my_toolkit


Don't forget to fill in the API port in this configuration.
Carsten
25 November 2013, 14:24
Thank you for your incredible fast reply Hugo. I give it a try, and leave a reply .
This topic has been closed.