Score:0

Failed to set up Apache for executing PERL file in FreeBSD

ru flag

I've successfully installed perl5 and apache24 in FreeBSD 12. Then I enabled apache24 in /etc/rc.conf and see index.html placed in the path /usr/local/www/apache24/data. Then in the file /usr/local/etc/apache24/httpd.conf I've uncommented the line

AddHandler cgi-script .cgi

inside of the <IfModule mime_module> and also added .pl at the end of the line.

Then I added in the same file the line

Options FollowSymLinks +ExecCGI

after the line

Options Indexes FollowSymLink

and restart Apache, but received the error

Either all Options must start with + or -, or no Option may

So I added the line without FollowSymLink and restart Apache without any errors. But if I follow by the link like mydomain.com/test.pl I still see my PERL code displayed as plain text instead of its executing.

My PERL code is

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "Hello world!";

If I run the code in command line by the command perl /usr/local/www/apache24/data/test.pl I receive my two lines i.e. Content-type: text/html and Hello world!. The file has permissions 755.

What else can I do to resolve the problem?

Score:1
ru flag

Ok, I've uncommented in httpd.conf also the line

LoadModule cgi_module libexec/apache24/mod_cgi.so

and now the code is executed successfully

my flag
I'm glad you figured this out and thanks for sharing your solution. It might also be worth noting that the extension of your `AddHandler` is different than the file you are trying to run.
stckvrw avatar
ru flag
Yes, I know. As I mentioned in the question, I added `.pl` to `AddHandler` and my file is `test.pl`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.