Bekijk de volledige versie : Tip: lighttpd & php code in html files

22-05-2007, 20:59

Sometime you need to run html file(s) as php pages. As it can be under Apache web server. To treat html pages as php you need to map multiple extensions to the same fastcgi server using fastcgi.map-extensions directive.
Simple add the following code to the fastcgi module in your /opt/etc/lighttpd/lighttpd.conf:

fastcgi.map-extensions = ( ".html" => ".php" )
The complete fastcgi module should be like this:

#### fastcgi module
## read fastcgi.txt for more info
fastcgi.map-extensions = ( ".html" => ".php" )
fastcgi.server = ( ".php" =>
( "localhost" =>
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/opt/bin/php-fcgi"

After this modifikation you can test this new function with the following html code:


<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>php in html files</title>

<p>This is a html text...<br></p>

echo "...and here come a simple php function: ",date("d.m.Y",time())," - ",date("H:i",time());

Save this code in an html file and upload the new html file to your php web server.

Good luck! :)