项目

一般

资料

操作

PHP操作指南

Lighttpd 配置

setup {
    module_load ( "mod_fastcgi" );
}

php = {
    if phys.path =$ ".php" {
        if physical.is_file {
            fastcgi "unix:/var/run/lighttpd/sockets/www-default-php.sock";
        }
    }
};

# ... some vhost/directory/whatever
# just use it in places where you want allow php.
# you need docroot before it (an alias / index if you need them)!

docroot "/var/www";
alias "/phpmyadmin" => "/usr/share/phpmyadmin";
index ( "index.php", "index.html" );

# if you want to use urls like http://example.com/index.php/some/path (using your php files like directories), you need this:
pathinfo;

php;

# ...

启动 PHP

一个简单的 ./run 脚本,用于通过 spawn-fcgi 和 runit/daemontools 启动 PHP

#!/bin/sh

exec 2>&1

PHP_FCGI_CHILDREN=2 \
PHP_FCGI_MAX_REQUESTS=10000 \
LANG=C LC_ALL=C \
exec /usr/bin/spawn-fcgi -n -s /var/run/lighttpd/sockets/www-default-php.sock -u www-default -U www-data -- /usr/bin/php5-cgi

php-fpm

这将扩展名为 .php 的物理文件和特殊 URL "/fpm-status" 指向 PHP。

-- php-fpm.lua

local function phpfpm(act)
    return action.when(physical.path:suffix(".php"),
        action.when(physical.is_file:is(), act),
        action.when(request.path:eq("/fpm-status"), act)
    )
end

actions = {
    ["phpfpm"] = phpfpm,
}
setup {
    module_load ( "mod_fastcgi", "mod_lua" );
    lua.plugin "/etc/lighttpd2/php-fpm.lua";
}

php = {
    phpfpm { fastcgi "unix:/var/run/lighttpd2-php-www-default.sock"; };
};

或者,不使用 lua 助手(它只在启动时运行,不涉及运行时 lua)

setup {
    module_load ( "mod_fastcgi" );
}

php = {
    if phys.path =$ ".php" {
        if physical.is_file {
            fastcgi "unix:/var/run/lighttpd/sockets/www-default-php.sock";
        }
    } else if request.path == "/fpm-status" {
        fastcgi "unix:/var/run/lighttpd2-php-www-default.sock";
    }
};

stbuehler12 年多前更新 · 7 次修订