如何在 PHP 的 lighttpd 中自定义标志和值?
也许已经有人问过这个问题,但我对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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
我的经验与@scribble 的注释相符:你不能直接设置 PHP 标志。但是,您可以让lighttpd 将环境变量传递给PHP,然后可以通过
$_SERVER
访问这些变量。如果您需要应用程序根据其运行的服务器动态配置自身,这会很方便。共享配置或初始化脚本可以从$_SERVER
读取值并使用ini_set
等来配置自身。
当然,如果您只使用单个配置,则可以编辑
php.ini
或通过ini_set
将这些更改直接添加到应用程序。下面是一个传递 MY_VARIABLE 的 lighttpd 配置指令示例:
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 useini_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 viaini_set
.Here's an example lighttpd configuration directive that passes
MY_VARIABLE
: