要配置Lighttpd以使用PHP,您需要首先確保已經(jīng)安裝了Lighttpd、PHP和FastCGI
對(duì)于Debian/Ubuntu系統(tǒng):
sudo apt-get install lighttpd php-cgi php-fpm
對(duì)于CentOS/RHEL系統(tǒng):
sudo yum install lighttpd php-cgi php-fpm
對(duì)于Debian/Ubuntu系統(tǒng):
sudo systemctl enable php7.4-fpm
sudo systemctl start php7.4-fpm
對(duì)于CentOS/RHEL系統(tǒng):
sudo systemctl enable php-fpm
sudo systemctl start php-fpm
/etc/lighttpd/lighttpd.conf
),以便將PHP請(qǐng)求傳遞給PHP-FPM。在文件末尾添加以下內(nèi)容:fastcgi.server = ( ".php" =>
((
"socket" => "/run/php/php7.4-fpm.sock",
"bin-path" => "/usr/sbin/php-cgi",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"broken-scriptfilename" => "enable"
))
)
請(qǐng)注意,根據(jù)您的系統(tǒng)和PHP版本,您可能需要調(diào)整socket
和bin-path
路徑。
對(duì)于Debian/Ubuntu系統(tǒng):
sudo systemctl restart lighttpd
對(duì)于CentOS/RHEL系統(tǒng):
sudo systemctl restart lighttpd
現(xiàn)在,Lighttpd應(yīng)該已經(jīng)配置為使用PHP處理.php
文件。您可以創(chuàng)建一個(gè)名為info.php
的文件,其中包含以下內(nèi)容,以測(cè)試PHP是否正常工作:
<?php
phpinfo();
?>
將此文件放置在Lighttpd的Web根目錄中(例如,/var/www/html/
),然后通過(guò)瀏覽器訪問(wèn)http://your_server_ip/info.php
,您應(yīng)該看到PHP信息頁(yè)面。