Cgi/perl 脚本在蒙特雷中显示为代码
这些脚本在升级到蒙特利之前运行良好! 我已按照“etresoft”中有关编辑 httpd.conf
文件并重新启动 Apache 的教程进行操作,但执行时 Perl 脚本(代码)会显示在 Safari 中。这些脚本位于我的 Sites
目录中,并在从那里运行时正确执行。
有一套 cgi/perl 脚本可用于管理和呈现家庭预算。 第一个脚本打开一个数据文件,其中包含各种帐户:支出(如杂货、水电费等)和收入。该脚本呈现一个带有大表的 HTML 文件,表中的每一行记录一个帐户、到期金额和时间。该脚本允许您编辑各种值。从此表页面可以调用另一个脚本,该脚本将显示当月到期的帐户并计算欠款总额、总收入和差额。
这些是对 /etc/apache2/httpd.conf
所做的编辑:
启用 php 和 perl:
LoadModule php_modul/usr/local/opt/[email protected]/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
LoadModule perl_module libexec/apache2/mod_perl.so
取消注释 userdir_module
的 LoadModule
:
LoadModule userdir_module libexec/apache2/mod_userdir.so
取消注释httpd-userdir.conf
的 include
行: 用户主目录
Include /private/etc/apache2/extra/httpd-userdir.conf
保存 httpd.conf
文件。
这是对 /etc/apache2/extra/httpd-userdir.conf
所做的编辑:
*.conf
的 Include
行
Include /private/etc/apache2/users/*.conf
取消注释我编辑的 /etc/apache2/users/<您的短用户名>.conf
。现在看起来像这样:
<Directory "/Users/rjklaus/Sites/">
AddLanguage en .en
AddHandler perl-script .pl
Options Indexes MultiViews FollowSymLinks Includes ExecCGI
DirectoryIndex index.html index.cgi index.php
AllowOverride None
Require host localhost
</Directory>
从“终端”窗口运行以下命令:
chmod +a "_www allow execute" ~
我运行 apachectl configtest 并收到“语法正常”。
接下来,我在 Safari 地址栏中输入了 http://localhost/
。我没有看到“它有效!”我被告知要期待。相反,我得到:
/Users/rjklaus/Ray's%20Stuff/HTML%20Budget/test.pl
“HTML Budget”是“Ray's Stuff”子目录中的一个文件(不是目录)。文本字符串“test.pl”不在该文件中。 Test.pl 是我的 Sites 目录中的一个简短的 perl 脚本。
我正在从 /usr/bin/perl 运行 perl v5.30.3。
Apache2 共有三个版本,位于 /Users/Shared/ 子目录中,标记为: 以前搬迁的物品, 先前重新安置的项目 1,以及 先前搬迁的物品 2.
These scripts worked fine prior to upgrading to Monterey!
I have followed the tutorial from “etresoft” regarding editing the httpd.conf
file and restarting Apache, but when executed the Perl script (code) displays in Safari. The scripts live in my Sites
directory, and execute properly when run from there.
There are a suite of cgi/perl scripts that function to manage and present a family budget.
The first script opens a data file that contains various accounts: expenses (like groceries, utilities, etc.) and incomes. The script presents an HTML file with a large table, each line in the table documents an account, how much is due, and when. The script allows you to edit the various values. From this table page it is possible to call another script which will present those accounts due for the month and calculate the total amounts owed and the total incomes and the difference.
These are the edits made to /etc/apache2/httpd.conf
:
Enabled the php and perl:
LoadModule php_modul/usr/local/opt/[email protected]/lib/httpd/modules/libphp.so
<FilesMatch \.phpgt;
SetHandler application/x-httpd-php
</FilesMatch>
LoadModule perl_module libexec/apache2/mod_perl.so
Uncommented the LoadModule
for userdir_module
:
LoadModule userdir_module libexec/apache2/mod_userdir.so
Uncommented the Include
line for httpd-userdir.conf
:
User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf
Saved the httpd.conf
file.
This is the edit made to /etc/apache2/extra/httpd-userdir.conf
:
Uncommented the Include
line for *.conf
Include /private/etc/apache2/users/*.conf
I edited /etc/apache2/users/<your short user name>.conf
. It now looks like this:
<Directory "/Users/rjklaus/Sites/">
AddLanguage en .en
AddHandler perl-script .pl
Options Indexes MultiViews FollowSymLinks Includes ExecCGI
DirectoryIndex index.html index.cgi index.php
AllowOverride None
Require host localhost
</Directory>
From a “Terminal” window I ran the following command:
chmod +a "_www allow execute" ~
I ran apachectl configtest
and received a “Syntax OK”.
I next entered http://localhost/
into the Safari address bar. I did NOT see the “It works!” that I was told to expect. Instead I got:
/Users/rjklaus/Ray's%20Stuff/HTML%20Budget/test.pl
“HTML Budget” is a file (not a directory) in a subdirectory of “Ray’s Stuff”. The text string “test.pl” is not in that file. Test.pl is a short perl script in my Sites directory.
I am running perl v5.30.3 from /usr/bin/perl.
There are three versions of Apache2 located in /Users/Shared/ subdirectories labeled:
Previously Relocated Items,
Previously Relocated Items 1, and
Previously Relocated Items 2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了确定 cgi_module 是否已启用?
just to be sure, the cgi_module is enabled?