OPNsense Forum

English Forums => General Discussion => Topic started by: ramhack on June 16, 2017, 02:14:50 pm

Title: Running PHP file on Captive Portal
Post by: ramhack on June 16, 2017, 02:14:50 pm
Hello everyone,

I have a question: How can I use a index.php file instead of a index.html when using Captive Portal ?

I tried modifying the /var/etc/lighttpd-cp-zone-0.conf of the file and added the following config (in order to run PHP code):

#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = ( ".php" =>
   ( "localhost" =>
      (
         "socket" => "/tmp/php-fastcgi.socket",
         "min-procs" => 1,
         "bin-environment" => (
            "PHP_FCGI_CHILDREN" => "16",
            "PHP_FCGI_MAX_REQUESTS" => "250"
         ),
         "bin-copy-environment" => (
            "PATH", "SHELL", "USER" ),
         "bin-path" => "/usr/local/bin/php-cgi",
         "broken-scriptfilename" => "enable"
      )
   )
)

The problem is, when I use the following command (and the Captive Portal -> 192.168.1.10:8000 doesn't work):

root@FreeBSD:/var/etc # lighttpd -tt -f lighttpd-cp-zone-0.conf
2017-06-16 12:03:07: (mod_fastcgi.c.1478) invalid "bin-path" => "/usr/local/bin/php-cgi" (check that file exists, is regular file, and is executable by lighttpd)

When I remove the following line (from the config file), everything works (beside PHP):

"bin-path" => "/usr/local/bin/php-cgi",

192.168.1.10:8000/index.html -> OK
192.168.1.10:8000/index.php -> 503 Service Not Available

My questions are: How can I solve this issue ? or How can I run PHP files in Captive Portal ?

Thank you !