[英]How to run multiple php version in lighttd server at same time?
我有几个 php 项目,其中包含多个 php 版本,例如 php 5.6、php 7.0 等。
最近,我安装了 lighttpd 服务器作为本地服务器。 这是我的 lighttpd.conf
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_fastcgi",
"mod_redirect",
# "mod_rewrite",
)
server.document-root = "/home/andrew/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
## Use ipv6 if available
#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"
dir-listing.activate = "enable"
include "localhost.81.conf"
而localhost.81.conf
是:
$SERVER["socket"] == ":81" {
server.document-root = "/home/andrew/www7"
}
我已经安装了 php5.6-cgi 和 php7.0-cgi,当启用 fastcgi-php5.6 时,php 5.6 可以工作,当启用 fastcgi-php7.0 时,php 7.0 可以工作。
mods fastcgi-php5.6:
## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi5.6",
"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"
))
和 mod fastcgi-php7.0:
## Start an FastCGI server for php (needs the php7-cgi package)
fastcgi.server += ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi7.0",
"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"
))
我不能同时启用两个 fastcgi-php。 但是我希望端口 80 可以与 php 5.6 一起使用,而端口 81 可以与 php7.0 一起使用。
可以在 lighttpd 服务器中使用吗? 在lighttpd上运行多个php版本的配置是什么?
您可以从 conf-available 文件夹更新您的 fastcgi-php。
$ cd /etc/lighttpd/conf-available/
制作备份文件:
$ sudo cp 15-fastcgi-php.conf 15-fastcgi-php.conf.save
现在打开15-fastcgi-php.conf
并更新如下:
$ sudo vi 15-fastcgi-php.conf
并粘贴以下代码片段:
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi5.6",
"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"
))
)
$SERVER["socket"] == ":81" {
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi7.0",
"socket" => "/var/run/lighttpd/php81.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER"
),
"broken-scriptfilename" => "enable"
))
)
}
现在,保存并关闭并启用该模块。
$ sudo lighty-enable-mod fastcgi-php
重新加载并重启服务器:
$ sudo systemctl force-reload lighttpd
$ sudo systemctl restart lighttpd
我希望它会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.