Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Aug 31, 2014 8:44 pm 
Offline
Senior Newbie

Joined: Tue Aug 05, 2014 12:00 pm
Posts: 6
So I've been managing a nice fastcgi setup for a single domain for awhile now and I'd like to expand this to two domains, one of which will host a wiki. I own both domains already and have been using separate services (pythonanywhere+linode) for them and am ready to consolidate and get a bit more serious.

Here is my current config...

lighttpd.conf:

Code:
#include "conf.d/cgi.conf"
include "conf.d/fastcgi.conf"

server.modules = (
        "mod_access",
        "mod_fastcgi",
        "mod_alias",
        "mod_rewrite",
        "mod_accesslog",
        "mod_compress",
        "mod_redirect"
)

server.port = 80
server.username = "http"
server.groupname = "http"
server.errorlog = "/var/log/lighttpd/error.log"

server.document-root = "/srv/http/site1.com/"

$HTTP["host"] == "site2.com" {
        server.document-root = "/srv/http/site2.com/"
}

dir-listing.activate = "disable"
index-file.names = ( )
#ssl.engine = "enable"
#ssl.pemfile = "/etc/lighttpd/certs/www.example.com.pem"
mimetype.assign = (
        ".html" => "text/html",
        ".txt" => "text/plain",
        ".css" => "text/css",
        ".js" => "application/x-javascript",
        ".jpg" => "image/jpeg",
        ".jpeg" => "image/jpeg",
        ".gif" => "image/gif",
        ".png" => "image/png",
        ".mng" => "video/x-mng",
        ".svg" => "image/svg+xml",
        "" => "application/octet-stream"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc", ".py" )
fastcgi.debug = 1


fastcgi.conf
Code:
$HTTP["host"] == "(^|\.)site1\.com$" {
        fastcgi.server = ( "/site1.py" => ((
                "socket" => "/tmp/fastcgi2.socket",
                "bin-path" => "/srv/http/site1.com/site1.py",
                "max-procs" => 1,
                "bin-environment" => (
                        "REAL_SCRIPT_NAME" => ""
                ),
                        "check-local" => "disable"
                )),
                ".php" => (
                        "localhost" => (
                                "host" => "127.0.0.1",
                                "port" => 1026,
                                "bin-path" => "/usr/bin/php-cgi",
                                "broken-scriptfilename" => "enable"
                        )
                )
        )

        url.rewrite-once = (
                "/static/(.*)$" => "/static/$1",
                "^/wikiroot/wiki/upload/(.+)" => "/wiki/upload/$1",
                "^/wikiroot/$" => "/w/index.php",
                "^/wikiroot/wiki/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2",
                "^/(.*)$" => "/site1.py/$1",
        )
}

$HTTP["host"] == "site2.com" {
        fastcgi.server = ( "/site2.py" => ((
                        "socket" => "/tmp/fastcgi.socket",
                        "bin-path" => "/srv/http/site2.com/site2.py",
                        "max-procs" => 1,
                        "bin-environment" => (
                                "REAL_SCRIPT_NAME" => ""
                        ),
                        "check-local" => "disable"
                ))
        )

        url.rewrite-once = (
                "^/static/(.*)$" => "/static/$1",
                "^/(.*)$" => "/site2.py/$1",
        )

}


/etc/hosts
Code:
<ipaddress>   site1.com       myhostname
<ipv6address>  site1.com       myhostname
<ipaddress>   site2.com   myhostname
<ipv6address> site2.com   myhostname
127.0.0.1       localhost.localdomain   localhost
#::1            localhost.localdomain   localhost


DNS Records
Code:
I am currently sending @ and www to an a record of <ipaddress> for both site1 and site2 on enom.


Currently, fastcgi/lighttpd isn't printing out any syntax errors or anything and site2 works like a charm, buit site1 does not for some reason and gives a 404.


edit: Sorry for this, but I just solved it myself (isn't that always the way of these things? You post the question after hours of working on it, then you solve it within minutes).

I changed the conditional for site1 in fastcgi.conf to...

Code:
$HTTP["host"] =~ "^(www\.)?site1.com" {


And it worked like a dream.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group