#
# (1) the /cgi-bin needs its uid and gid to be owned by http! otherwise infinite strange loop occurs
# (2) the following error: mod_fcgid: error reading data from FastCGI server, End of script output before headers: hello.cgi
#     -> it can be fixed by changing back to "AddHandler cgi-script .cgi", but I don't want that, I want fastcgi
#     -> the "End of script output before headers: fastcgi-php-wrapper" actually happened when fastcgi-php-wrapper was using 'php-cgi'
#        that did not exist on my system, therefore that wrapper script ENDED/PRINTED (nothing) before HEADERS (because headers never were sent back!)
#     -> this might mean that mod_fcgid/mod_fastcgi need wrappers for all file extensions, e.g. spawn /bin/bash for .sh, spawn php-cgi for .php, etc.
#
# - look like there are 2 ways to spawn wrappers, (1) via FcgidWrapper or FastCgiWrapper and (2) via new 'AddHandler' and 'Action'
# - to verify fastcgi is used use phpinfo() and look for "Server API = CGI/FastCGI"
# - php_admin_value directive is not available in cgi mode!
#

<IfModule fcgid_module>
    AddHandler php-fcgid .php
    AddType application/x-httpd-php .php
    DirectoryIndex index.php index.html
    Action php-fcgid /cgi-bin/fastcgi-php-wrapper
    <Location /cgi-bin/>
        # below SetHandler is not needed but nice for shebanged .sh or .pl scripts
        SetHandler cgi-script
        Options +FollowSymLinks +ExecCGI
    </Location>

#    <FilesMatch "\.php$">
#        # with this i enable php via fastcgi server wide, might want to narrow it down to specific vhosts
#        # SetHandler is am override, redundant here since AddHandler already registered .php extension
#        SetHandler php-fcgid
#        # below probably redundant since it looks like only the wrapper needs this bit ON
#        Options +ExecCGI
#    </FilesMatch>

</IfModule>


# almost worked, blew up on:
#
# mod_fcgid: error reading data from FastCGI server
# [Sun Nov 30 01:00:59.663064 2014] [core:error] [pid 11886] [client ::1:46027] End of script output before headers: php-fcgid-wrapper
#
# what a fucking joke