简体   繁体   中英

Cgi/perl scripts display as code in Monterey

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/php@8.0/lib/httpd/modules/libphp.so
 <FilesMatch \.php$>
  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.

just to be sure, the cgi_module is enabled?

<IfModule !mpm_prefork_module>
    LoadModule cgid_module lib/httpd/modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
    LoadModule cgi_module lib/httpd/modules/mod_cgi.so
</IfModule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM