Project

General

Profile

using php & mono on the same lighttpd server

Added by warped over 12 years ago

Hi,
I'm fighting with this issue last few days and decided to ask for help. My situation:
I have Archlinux server with lighttpd 1.4.30. On this server I have php app (MythWEB), some content to download (gPXE image files for diskless stations). I want to add mono based app (mobilemyth). Author of this app already prepared http server config for apache.

My issue is how to configure lighttpd for successful support php, mono & static html content.

Some details:
-my lighttpd server document-root is /var/http/
-mythweb app (php) in under /var/http/mythweb
-mobilemyth app (mono) is under /var/http/mobilemyth

Currently I'm able to successfully use mobilemyth (mono app) when I set
lighttpd & mono server document-root paths as /var/http/mobilemyth

Unfortunately my other apps (ythweb, gPXE, etc) needs server document-root as /var/http/

Currently I setup fast.cgi that for .aspx pages document-root is
/var/http/mobilemyth (see below .conf file). This gives me partially working mobilemyth but it's web pages hasn't
static graphical elements. Not strange as all other than .aspx
mobilemyth pages have wrong document-root.

May somebody hint me about proper lighttpd config for my case. I suspect lighttpd config
should emulate virtual hosting setup provided for Apache (see below) - but
translating it to lighttpd world seems to be beyond my current
lighttpd skills :-(

apache virtual server config:

Alias /mobilemyth "/var/www/mobilemyth" 

MonoServerPath mobilemyth "/usr/bin/mod-mono-server4" 
MonoDebug mobilemyth true
MonoApplications mobilemyth "/mobilemyth:/var/www/mobilemyth" 

<Location "/mobilemyth">
    Allow from all
    Order allow,deny
    MonoSetServerAlias mobilemyth
    SetHandler mono
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>

My current lighttpd.conf file (it gives partially working mono app):

server.modules              = (
                               "mod_rewrite",
                               "mod_access",
                               "mod_auth",
                               "mod_setenv",
                               "mod_fastcgi",
                               "mod_cgi",
                               "mod_webdav",
                               "mod_accesslog" )

server.document-root        = "/var/http/" 

# server.username             = "http" 

# server.groupname            = "http" 

server.errorlog-use-syslog  = "enable" 

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm" , "mythweb.php",
                                "index.aspx", "default.aspx",
                            )

include "/etc/lighttpd/mono.conf" 

mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".wav"          =>      "audio/x-wav",
  ".m4a"          =>      "audio/x-m4a",
  ".gif"          =>      "image/gif",
  ".jar"          =>      "application/x-java-archive",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".ogv"          =>      "video/ogg",
  ".ogg"          =>      "video/ogg",
  ".webm"         =>      "video/webm",
  ".ts"           =>      "video/MP2T",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar",
  ".m3u8"         =>      "application/x-mpegURL",
  # default mime type
  ""              =>      "application/octet-stream",
 )

# debug.log-request-handling = "enable" 

accesslog.filename          = "/var/log/web-access.log" 

url.access-deny             = ( "~", ".inc" )

$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable" 
}

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

server.pid-file            = "/var/run/lighttpd.pid" 

server.reject-expect-100-with-417 = "disable" 

fastcgi.server = (
        ".php" => ((
            "bin-path" => "/usr/bin/php-cgi",
            "socket"   => "/var/run/mythtv-php-fcgi.socket",
            "broken-scriptfilename" => "enable",
            "bin-environment" => (
                "db_server"   => "localhost",
                "db_name"     => "mythconverg",
                "db_login"    => "mythtv",
                "db_password" => "mythtv" 
            )
        )),
        ".aspx" => ((
            "socket" => mono_shared_dir + "fastcgi-mono-server4",
            "bin-path" => mono_fastcgi_server,
            "bin-environment" => (
                "PATH" => "/bin:/usr/bin:" + mono_dir + "bin",
                "LD_LIBRARY_PATH" => mono_dir + "lib:",
                "MONO_SHARED_DIR" => mono_shared_dir,
                "MONO_FCGI_LOGLEVELS" => "Standard",
                "MONO_FCGI_LOGFILE" => mono_shared_dir + "fastcgi.log",
                "MONO_FCGI_ROOT" => mono_fcgi_root,
                "MONO_FCGI_APPLICATIONS" => mono_fcgi_applications
            ),
            "max-procs" => 1,
            "check-local" => "disable" 
        ))
)

setenv.add-environment = (
             "db_server"   => "localhost",
             "db_name"     => "mythconverg",
             "db_login"    => "mythtv",
             "db_password" => "mythtv" 
)

cgi.assign = ( ".pl"  => "/usr/bin/perl",
               ".cgi" => "/usr/bin/perl" 
)

url.rewrite-once = (
       "^/{1,2}mythweb/(css|data|images|js|themes|skins|[a-z_]+\.(php|pl)).*" => "$0",
       "^/{1,2}mythweb/(pl(/.*)?)$" => "/mythweb/mythweb.pl/$1",
       "^/{1,2}mythweb/(.+)$"       => "/mythweb/mythweb.php/$1",
       "^/{1,2}mythweb/(.*)$"       => "/mythweb/mythweb.php" 
)

$HTTP["url"] =~ "^/minimyth/conf-rw($|/)" {
    webdav.activate = "enable" 
  }

include "/etc/lighttpd/auth-inc.conf"

fastcgi conf for mono:

var.mono_dir = "/usr/" 
var.mono_shared_dir = "/myth/tmp/" 
var.mono_fastcgi_server = mono_dir + "bin/" + "fastcgi-mono-server4" 
# var.mono_fcgi_root = server.document-root
var.mono_fcgi_root = "/var/http/mobilemyth" 
# var.mono_fcgi_root = "/var/http/" 
var.mono_fcgi_applications = "/:."<pre>