在Raspberry Pi上运行Apache2
使用Raspberry Pi运行Apache2。
让PHP和Perl正常运行。
<?php
foreach ($_SERVER as $key => $val)
{
echo $key . ' : ' . $val . '<br />';
}
?>
#! /usr/bin/perl
#
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
print "<title>Hello by Perl</title>\n";
print "</head>\n";
print "<body>\n";
print "Hello<p />\n";
print "こんにちは<p />\n";
print "Jun/16/2020<p />\n";
print "</body>\n";
print "</html>\n";
安裝 Apache2
sudo apt install apache2
仅需安装便可启动。
检查状态。
sudo systemctl status apache2

安装 PHP
sudo apt install php php-cli php-curl
确认 PHP 版本
$ php --version
PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.27-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

Perl的设置
版本检查
$ perl --version
This is perl 5, version 28, subversion 1 (v5.28.1) built for arm-linux-gnueabihf-thread-multi-64int
(with 61 registered patches, see perl -V for more detail)
Copyright 1987-2018, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
启用 CGI
sudo a2enmod cgid
sudo systemctl restart apache2
在/etc/apache2/apache2.conf文件中添加以下内容。
(省略)
AddHandler cgi-script .cgi .pl
访问页面时,
Forbidden
You don't have permission to access this resource.
Apache/2.4.38 (Raspbian) Server at tulip.local Port 80
更改 /etc/apache2/apache2.conf 的配置
<Directory /var/www/>
Options Indexes FollowSymLinks ExecCGI
AllowOverride None
Require all granted
</Directory>

我在下一个版本中进行了确认。
$ uname -a
Linux violet 5.10.17-v7l+ #1414 SMP Fri Apr 30 13:20:47 BST 2021 armv7l GNU/Linux