2014-04-28 33 views
2

我有工作lighttpd + django服務器,但我想要的PHP也是例如: www.mydomian.com是django主頁和www.mydomian.com/owncloud是owncloud分佈。有可能做到這一點?我可怕的英語真的很抱歉;)這是我的lighttpd.confphp和django在同一個lighttpd服務器上

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

) 
server.document-root  = "/var/www" 
server.upload-dirs   = ("/var/cache/lighttpd/uploads") 
server.errorlog    = "/var/log/lighttpd/error.log" 
server.pid-file    = "/var/run/lighttpd.pid" 
server.username    = "www-data" 
server.groupname   = "www-data" 
server.port     = 80 


index-file.names   = ("index.php", "index.html", "index.lighttpd.html") 
url.access-deny    = ("~", ".inc") 
static-file.exclude-extensions = (".php", ".pl", ".fcgi") 

compress.cache-dir   = "/var/cache/lighttpd/compress/" 
compress.filetype   = ("application/javascript", "text/css", "text/html", "text/plain") 

# default listening port for IPv6 falls back to the IPv4 port 
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port 
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

$SERVER["socket"] == "localhost:443" { 
    ssl.engine = "enable" 
     ssl.pemfile = "/etc/lighttpd/ssl/server.pem" 
    } 
$HTTP["url"] =~ "^/owncloud/data/" { 
     url.access-deny = ("") 
} 

#$SERVER["socket"] == "localhost:8000" { 
#server.document-root = "/var/www/" 
# prawa dostępu dla "http" 


fastcgi.server += (
    "/projekt.fcgi" => (
     "main" => (
      "host" => "127.0.0.1", 
      "port" => 3033, 
      #"socket" => "/var/www/projekt.sock", 
      "check-local" => "disable", 
     ) 
    ) 
) 
fastcgi.server += (
    "/admin.fcgi" => (
     "admin" => (
      "host" => "127.0.0.1", 
      "port" => 3033, 
      #"socket" => "/var/www/projekt.sock", 
      "check-local" => "disable", 
     ) 
    ) 
) 
alias.url = (
    "/static" => "/var/www/static", 
    "/media" => "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/", 
) 
url.rewrite-once = (
"^(/static.*)$" => "$1", 
"^(/Media.*)$" => "$1", 
"^(/.*)$" => "/projekt.fcgi$1", 
"^(/owncloud.*)$" => "index.php$1", 
) 
#} 

這:

# -*- depends: fastcgi -*- 
# /usr/share/doc/lighttpd/fastcgi.txt.gz 
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi 

## Start an FastCGI server for php (needs the php5-cgi package) 
fastcgi.server += (".php" => 
    ((
     "bin-path" => "/usr/bin/php-cgi", 
     "socket" => "/var/run/lighttpd/php.socket", 
     "max-procs" => 1, 
     "bin-environment" => ( 
      "PHP_FCGI_CHILDREN" => "4", 
      "PHP_FCGI_MAX_REQUESTS" => "10000" 
     ), 
     "bin-copy-environment" => (
      "PATH", "SHELL", "USER" 
     ), 
     "broken-scriptfilename" => "enable" 
    )) 
) 

感謝您的幫助, Sierran

編輯現在

工作很棒。但是,SSL只能在服務器IP上工作,而不是在多米尼加。更新配置文件:

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

) 
server.document-root  = "/var/www/" 
server.upload-dirs   = ("/var/cache/lighttpd/uploads") 
server.errorlog    = "/var/log/lighttpd/error.log" 
server.pid-file    = "/var/run/lighttpd.pid" 
server.username    = "www-data" 
server.groupname   = "www-data" 
server.port     = 80 


index-file.names   = ("index.php", "index.html", "index.lighttpd.html") 
url.access-deny    = ("~", ".inc") 
static-file.exclude-extensions = (".php", ".pl", ".fcgi") 

compress.cache-dir   = "/var/cache/lighttpd/compress/" 
compress.filetype   = ("application/javascript", "text/css", "text/html", "text/plain") 

# default listening port for IPv6 falls back to the IPv4 port 
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port 
include_shell "/usr/share/lighttpd/create-mime.assign.pl" 
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

#$SERVER["socket"] == ":443" { 
# ssl.engine = "enable" 
#  ssl.pemfile = "/etc/lighttpd/ssl/server.pem" 
# server.name = "mydomian.eu" 
#  
#} 


$HTTP["url"] =~ "^/owncloud/data/" { 
     url.access-deny = ("") 
} 


$SERVER["socket"] == ":443" { 
    ssl.engine = "enable" 
    ssl.pemfile = "/etc/lighttpd/ssl/server.pem" 
    $HTTP["host"] == "mydomian.eu" { 
      ssl.pemfile = "/etc/lighttpd/ssl/mydomian.eu.pem" 
     } 
    } 

$HTTP["host"] =~ "^(www\.)?mydomian\.eu" { 
server.document-root = "/var/www/" 
fastcgi.server += (
    "/projekt.fcgi" => (
     "main" => (
      "host" => "127.0.0.1", 
      "port" => 3033, 
      #"socket" => "/var/www/projekt.sock", 
      "check-local" => "disable", 
     ) 
    ) 
) 

url.rewrite-once = (
"^(/static.*)$" => "$1", 
"^(/Media.*)$" => "$1", 
"^(.*)$" => "/projekt.fcgi$1", 
) 
} 

alias.url = (
    "/static" => "/var/www/static", 
    "/media" => "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/", 
) 

回答

2

它並不真正的問題是什麼類型你正在運行(例如Apache時,lighttpd的,等等。),只要你能安裝必要的PHP和Python包服務器渲染軟件在操作系統本身(使用任何* nix服務器操作系統,如Ubuntu服務器/ CentOS,這是非常容易的)。

雖然我不熟悉的lighttpd,我會考慮是將owncloud軟件,而不是映射到一個子域:

owncloud.mydomain.com

與子域處理比/鏈接更容易網址。此外,你會避免與/ link的衝突,因爲你可能想在django本身(用於其他頁面)中創建更多鏈接。

您需要做的是使用lighttpd軟件爲網站的不同部分創建特殊用例。例如,你會爲一個規定:

mydomain.com/www.mydomain.com owncloud.mydomain.com

我希望我的邏輯是有道理的你。如果您需要更多信息,請對我的帖子發表評論,我們可以對其進行編輯,直到找到正確的答案。

+0

謝謝你的幫助。我搜索,當我有domian的時候很簡單,但現在我的服務器上只有ip addres:<我會在家裏嘗試更多。 – Sierran

+0

將域名映射到服務器的IP地址並不困難。只需進入您的域名公司帳戶並將服務器IP地址映射到域(除非您已經知道)。祝你好運。 – Joe

+0

工作Django +的PHP,但現在不是:<任何意見? – Sierran

相關問題