我想使用 Lighttpd 和 PHP 在 Windows 上提供轻量级独立 Web 服务器。我昨天下载了所有最新版本,一个小时后一切运行正常。
今天我改变了服务器.document-root从服务器根目录 + “/htdocs”到服务器根目录 + “/../htdocs”并相应地调整了我的目录结构。重新启动所有程序后,当我尝试访问 php 页面时,我在 Web 浏览器中看到“未指定输入文件”。
这是我的配置文件。当然,我也尝试过cgi.fix_pathinfo和fastcgi 服务器但我似乎找不到正确的设置。有什么想法吗?
php.ini
cgi.fix_pathinfo=1
extension_dir = .\ext
extension = php_pdo_sqlite.dll
date.timezone = UTC
log_errors = On
error_log = ..\logs\php_error.log
lighttpd配置文件
## modules to load
# at least mod_access and mod_accesslog should be loaded
server.modules = (
"mod_access",
"mod_accesslog",
"mod_fastcgi",
# "mod_cgi",
"mod_status"
)
#### include important configuration files
include "variables.conf"
include "mimetype.conf"
## a static document-root
## works fine
server.document-root = server_root + "/htdocs"
## causes "No input file specified"
#server.document-root = server_root + "/../htdocs"
# extensions that should not be handle via static-file transfer
static-file.exclude-extensions = ( ".php" )
## virtual directory listings
dir-listing.activate = "disable"
#directory for file uploads
server.upload-dirs = ( temp_dir )
# files to check for if .../ is requested
index-file.names = ( "index.php", "index.html" )
## set the event-handler (read the performance section in the manual)
server.event-handler = "libev"
## deny access the file-extensions
url.access-deny = ( "~", ".inc", ".htaccess" )
## disable range request for PDF files
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
#### status module
status.status-url = "/server-status"
status.config-url = "/server-config"
#### fastcgi module
fastcgi.server = ( ".php" => ("localhost" => ("host" => "127.0.0.1", "port" => 521, "broken-scriptfilename" => "enable" )))
#cgi.assign = ( ".php" => "C:/development/tds/PHP/php-cgi.exe" )
该目录结构有效
c:\base_dir
\php
\lightTPD
\htdocs
这是我想要实现的目录结构
c:\base_dir
\htdocs
\php
\lightTPD
答案1
我现在正在使用一种解决方法。
mklink /J htdocs ..\htdocs
如果有人有更好的解决方案我会很高兴听到。
答案2
检查 php.ini 中的 doc_root 是否设置正确
doc_root = C:\base_dir\htdocs
这就是我所需要的
如果您不想要绝对路径,您可以取消设置它,它也应该可以工作。
; doc_root = ""
刚刚尝试了一下,没有问题