如何在 PHP 的 lighttpd 中自定义标志和值?

发布于 2024-08-12 14:53:09 字数 254 浏览 1 评论 0原文

也许已经有人问过这个问题,但我对lighttpd是全新的,我想知道如何更彻底地配置它。

在 Apache 中,您可以将 PHP 标志和值设置为配置的一部分:

php_flag error_reporting OFf php_value error_log /path/to/log/file.log

有没有办法对lighttpd做同样的事情?

为了加分,关于完全配置 PHP 和 lighttpd 的精彩教程将是一个很棒的链接。

Perhaps this has already been asked, but I'm brand new to lighttpd and I'd like to know how to configure it more thoroughly.

In Apache, you can set PHP flags and values as a part of your configuration:

php_flag error_reporting OFf
php_value error_log /path/to/log/file.log

Is there a way to do the same with lighttpd?

For bonus points, a great tutorial on fully configuring PHP and lighttpd together would be an amazing link.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒解孤独 2024-08-19 14:53:09

Lighttpd Wiki 表明这对于网络来说是不可能的服务器在 CGI/FastCGI 下运行时传递 php 设置,并且 http://pecl.php.net/package /htscanner 将允许 php 直接解释 .htaccess 文件。

Lighttpd Wiki suggests that it's not possible for the web server to pass php settings when running under CGI/FastCGI and that http://pecl.php.net/package/htscanner will allow php to interpret .htaccess files directly.

我三岁 2024-08-19 14:53:09

我的经验与@scribble 的注释相符:你不能直接设置 PHP 标志。但是,您可以让lighttpd 将环境变量传递给PHP,然后可以通过$_SERVER 访问这些变量。如果您需要应用程序根据其运行的服务器动态配置自身,这会很方便。共享配置或初始化脚本可以从 $_SERVER 读取值并使用 ini_set等来配置自身。

当然,如果您只使用单个配置,则可以编辑 php.ini 或通过 ini_set 将这些更改直接添加到应用程序。

下面是一个传递 MY_VARIABLE 的 lighttpd 配置指令示例:

fastcgi.server = ( ".php" => ((
    "bin-path" => "/usr/local/bin/php-cgi",
    "socket" => "/tmp/php-fastcgi-"+var.PID+".socket",
    "max-procs" => 2,
    "bin-environment" => (
        "PHP_FCGI_CHILDREN" => "10",
        "PHP_FCGI_MAX_REQUESTS" => "100",
        "MY_VARIABLE" => "my-value"
    ),
    "bin-copy-environment" => (
        "PATH", "SHELL", "USER"
    ),
)))

My experience matches what @scribble notes: you can't set PHP flags directly. However, you can have lighttpd pass environment variables to PHP, which are then accessible via $_SERVER. This is convenient if you need your application to configure itself dynamically based on the server it's running on. A shared configuration or initialization script can read the value from $_SERVER and use ini_set, etc. to configure itself.

Of course, if you only every use a single configuration, you could edit php.ini or add these changes directly to the application via ini_set.

Here's an example lighttpd configuration directive that passes MY_VARIABLE:

fastcgi.server = ( ".php" => ((
    "bin-path" => "/usr/local/bin/php-cgi",
    "socket" => "/tmp/php-fastcgi-"+var.PID+".socket",
    "max-procs" => 2,
    "bin-environment" => (
        "PHP_FCGI_CHILDREN" => "10",
        "PHP_FCGI_MAX_REQUESTS" => "100",
        "MY_VARIABLE" => "my-value"
    ),
    "bin-copy-environment" => (
        "PATH", "SHELL", "USER"
    ),
)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文