|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|
||||
httpd fastcgi configuration and programming
I'm playing with the httpd(8) daemon (in 5.6-stable) but I'm a n00b to web tech and there isn't much information [that I've found] for OpenBSD's (new?) httpd other than the two brief man pages - (the other being httpd.conf(5)).
The man page says: "The FastCGI implementation has optional socket support". (Is there a way to use FastCGI without sockets?) Anyway, I am totally without a clue. Let's say I want to write a little C language FastCGI web application (something like a Hello, World program) as a way to begin to understand the overall architecture and configuration of the tech. Does anyone know how to do this? My current configuration is dead simple. /etc/httpd.conf is: Code:
prefork 1 server "default" { listen on 192.168.0.1 port 80 } If the configuration is modified to: Code:
prefork 1 fastcgi server "default" { listen on 192.168.0.1 port 80 } $ sudo httpd -n returns: "/etc/httpd.conf:2: syntax error"I found the www/fcgi port and an example tiny-fcgi.c but there's no mention of sockets anywhere anywhere in the code and after compiling it, I don't know what to do next. I'm such a newb, I need serious schooling. Any ideas? |
|
||||
If you have nginx and php running on the same machine then Unix-domain sockets would probably be more efficient than IP sockets.
unix domain sockets vs. internet sockets What seems nifty with the IP socket approach is the web app can be migrated to a machine other than the one on which the web server is running. OpenBSD's httpd manpage has no mention of configuring FastCGI to use IP sockets (AF_INET) but only Unix-domain sockets (AF_UNIX). However, the source (/usr/src/usr.sbin/httpd/server_fcgi.c) seems to suggest that IP sockets are possible [possibly ]. Side note: I figured out why the default AF_UNIX file for fastcgi is set to /run/slowcgi.sock. There is a FastCGI to CGI wrapper server - slowcgi(8) - in the base system that uses that socket and, from what I've seen so far, seems to work fairly seamlessly with httpd. But, alas, committed to figuring out web programming, I currently find myself eyeballs deep in the FastCGI Specification. Oh, the humanity! |
|
||||
"[no] fastcgi [socket socket]"
"socket" seems to be an optional override of the default location /run/slowcgi.sock. But whether or not to use fastcgi is configured on a per server basis, so maybe the correct syntax for my /etc/httpd.conf is: Code:
prefork 1 server "default" { listen on 192.168.0.1 port 80 fastcgi } $ sudo httpd -n returns: "configuration OK"Groovy. Thanks for the hint, jggimi! One step closer... |
|
||||
And this, regarding the development of slowcgi(8).
|
|
||||
I know you know. But you didn't seem to know that I know you know.
Quote:
|
|
||||
another step closer
This configuration seems to work: /etc/httpd.conf
Code:
server "default" { listen on 192.168.0.1 port 80 location "/*" { fastcgi socket "/run/test.sock" } } $ sudo nc -lU /var/www/run/test.sock As does this: /etc/httpd.conf Code:
server "default" { listen on 192.168.0.1 port 80 location "/*" { fastcgi socket ":8080" } } $ nc -l 127.0.0.1 8080 I haven't [yet] figured out how to specify an IP address for the AF_INET socket approach... |
|
|||
Hi hanzer,
Would it be possible to see your /etc/php-fpm.conf file as I'm curious as to how you managed to make fastcgi work. It seems that I'm missing something... and it's probably just in front of me. Thanks, Joh |
|
||||
Quote:
jggimi might be able to chime in with a hint for you. |
|
||||
Here's my php directive in nginx.conf I use on my net/nfsen server:
Code:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/htdocs/nfsen; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_param HTTPS on; } Code:
[global] [www] user = www group = www listen = 127.0.0.1:9000 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 chroot = /var/www Last edited by jggimi; 27th February 2015 at 12:35 AM. Reason: typographic (columns in code block) |
|
|||
Thanks jggimi for that example! I was able to make it work based on what you provided.
|
Tags |
httpd, httpd fastcgi, nginx, php-fpm.conf |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
httpd in OpenBSD 5.6 | jorisvh | OpenBSD Packages and Ports | 8 | 4th November 2014 12:14 AM |
php 5.3 fastcgi | Fekete | OpenBSD Packages and Ports | 5 | 16th July 2013 11:59 PM |
httpd problem or something else | c0mrade | Other BSD and UNIX/UNIX-like | 6 | 15th January 2009 09:19 PM |
httpd -DNOHTTPACCEPT | starbuck | FreeBSD General | 9 | 23rd August 2008 12:14 PM |
httpd.conf | Snoop1990 | General software and network | 5 | 29th July 2008 04:30 AM |