gpt4 book ai didi

php 和 django 在同一个 lighttpd 服务器上

转载 作者:太空宇宙 更新时间:2023-11-04 03:46:47 27 4
gpt4 key购买 nike

我有 lighttpd + django 服务器,但我也想使用 php,例如:www.mydomian.com 是 django 主页,www.mydomian.com/owncloud 是 owncloud 发行版。可以这样做吗?真的很抱歉我糟糕的英语 ;) 这是我的 lighttpd.conf

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"
))
)

感谢您的帮助,雪兰

编辑

现在工作得很好。但 SSL 仅适用于服务器 IP,不适用于 domian。更新的配置文件:

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/",
)

最佳答案

您运行的是什么类型的服务器渲染软件(例如 Apache、lighttpd 等)并不重要,只要您可以在操作系统本身上安装必要的 PHP 和 Python 包(带有任何 * nix-server 操作系统,如 Ubuntu-server/CentOS,这很容易做到。

虽然我不熟悉 lighttpd,但我会考虑将 owncloud 软件映射到子域:

owncloud.mydomain.com

处理子域比/link URL 容易得多。此外,您将避免与/link 发生冲突,因为您可能希望在 django 本身(用于其他页面)中创建更多链接。

您需要做的是使用您的 lighttpd 软件为网站的不同部分创建特殊用例。例如,您将为:

mydomain.com/www.mydomain.comowncloud.mydomain.com

我希望我的逻辑对你有意义。如果您需要更多信息,请评论我的帖子,我们可以对其进行编辑,直到找到正确的答案。

关于php 和 django 在同一个 lighttpd 服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23349675/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com