How to make Perl scripts run under Apache?

This problem is really simple, I guess. But I’ve searched documentation and forums without success …

I want to be able to run Perl scripts under Apache. I.e.: the user goes for the page http://myserver.com/info, a Perl script is run, and the script output returned to the user. Very much similar to awstats.pl .

This should happen also for external visitors to the web site. The web site in question (myserver.com) is run as a Virtual Server under Virtualmin.

I would like to place my scripts in another folder than cgi-bin .

How is this possible?

SYSTEM INFORMATION
OS type and version Debian Linux 12
Virtualmin version 7.20.2 Pro

Yes, it is possible of course.

You will have to use the cgi-bin directory. And make the files executable.

Couldn’t it be possible to create an alias for /info as well?

1 Like

How would I do that?

An alias to a script can be created as easy as:

ScriptAlias /info /home/ubuntu24-pro/cgi-bin/info.pl

Alternatively, you could use the UI for this purpose on the “Web Configuration ⇾ Configure SSL Website: CGI Programs” page.

1 Like

Thanks, it works for me. I’m migrating a planner program from another installation to Virtualmin. There I had one folder with both Perl scripts and various support files, e.g. configuration files. As I understand it, with your suggestion, I need to have the Perl files to be run as cgi-scripts in the cgi-bin folder, and place the other files in another folder. Is this true?

Isn’t it possible to place Perl files, meant to be run as cgi-scripts, in a custom folder?

It’s possible, but it would require changing the configuration. Since you’re asking, I’d recommend sticking to the defaults as much as you can.