• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

CGI Scripts with *.cgi Extension Not Recognized by Plesk 7 by Default?

P

perryv

Guest
Fresh from installation, I configured Plesk 7 so that Web users can run their own CGI scripts on the server. In addition, I also enabled Perl. When I tried to create a test CGI script with a *.cgi extension (i.e., test.cgi) and upload it to a test Web User's cgi-bin directory on the Plesk server, the script won't run. I checked if there is Execute access on that user's directory, and I found out that indeed it has. Yet my script won't run. But when i renamed the script into "test.pl" (the extension is now *.pl), the test script ran successfully! I tried to add *.cgi as a text/plain content type in MIME Types, but still my *.cgi script version won't run. How should I configure Plesk 7 so that it can also run *.cgi scripts?
 
I think it has nothing to do with the Perl installed by Plesk 7. Plesk installed ActivePerl 5.8.1 on my system. I think it has something to do with the IIS configuration which the installer apparently forgot to configure for *.cgi script support.
 
1. Start IIS manager console.
2. expand Web Sites item in tree view
3. Select web site which you want to associate cgi extension with Perl, right click on it and choose Properties.
4. Click Home Directory -> Configuration -> Mappings, select .pl extension, click on Edit button
5. Copy text in edit box "Executable" to clipboard and click Cancel button.
6. You are on a mapping dialog now (p.4). Click on 'Add..' button.
7. Paste from clipboard text to editbox "Executable". Write ".cgi" without quotes in Extension text box. Click Ok button.

Do the same on all domains which you allow Perl support. If you allow Perl for all domains, process points 1-7 on parent item "Web Sites". All new websites will inherit these settings. IIS will ask whether to apply changes on existing sites.
 
I have a question regarding cgi scripts. What do you place at the top of the scripts? I know on Linux machines it is something like this #!/usr/bin/perl. Is this the same? Also if customers are using mail scripts on Linux the path to sendmail was something like /usr/lib/sendmail, what do customer use on Windows cgi-based scripts? We use mailenable? Thanks in advance.
 
In Windows, if you're using IIS, then what you put at the top of your scripts doesn't matter. But if you're using Apache in Windows, then the top of your script should be the full path and filename (minus the file extension) of your Perl interpreter. Example: If your perl.exe is located in C:\Perl\bin , then the top of your script should be:

#!C:\Perl\bin\perl

If your scripts are in the same drive as perl.exe, (i.e., your scripts and perl.exe are both on Drive C: ) then you can shorten the above line to

#!\Perl\bin\perl

You can also use forward slashes (/) instead of backslashes in the path, so the above examples can be written as

#!C:/Perl/bin/perl

#!/Perl/bin/perl


Personally, I install my Perl in C:/usr/bin , so the top of my script is

#!/usr/bin/perl

That way, I can easily port my script to Linux and back without changing anything. :)

As for the Windows mailer program, there's no sendmail built into Windows. People either use MS Exchange, Mail Enable, the commercial Windows port of sendmail, etc. But I think in Windows (and recommended on Linux too) you should use Net::SMTP and Net::pOP3 in your mail scripts.
 
Originally posted by perryv
In Windows, if you're using IIS, then what you put at the top of your scripts doesn't matter. But if you're using Apache in Windows, then the top of your script should be the full path and filename (minus the file extension) of your Perl interpreter. Example: If your perl.exe is located in C:\Perl\bin , then the top of your script should be:

#!C:\Perl\bin\perl

If your scripts are in the same drive as perl.exe, (i.e., your scripts and perl.exe are both on Drive C: ) then you can shorten the above line to

#!\Perl\bin\perl

You can also use forward slashes (/) instead of backslashes in the path, so the above examples can be written as

#!C:/Perl/bin/perl

#!/Perl/bin/perl


Personally, I install my Perl in C:/usr/bin , so the top of my script is

#!/usr/bin/perl

That way, I can easily port my script to Linux and back without changing anything. :)

As for the Windows mailer program, there's no sendmail built into Windows. People either use MS Exchange, Mail Enable, the commercial Windows port of sendmail, etc. But I think in Windows (and recommended on Linux too) you should use Net::SMTP and Net::pOP3 in your mail scripts.
Thanks for the info, this is just what we were looking for.
 
Originally posted by shwonder
1. Start IIS manager console.
2. expand Web Sites item in tree view
3. Select web site which you want to associate cgi extension with Perl, right click on it and choose Properties.
4. Click Home Directory -> Configuration -> Mappings, select .pl extension, click on Edit button
5. Copy text in edit box "Executable" to clipboard and click Cancel button.
6. You are on a mapping dialog now (p.4). Click on 'Add..' button.
7. Paste from clipboard text to editbox "Executable". Write ".cgi" without quotes in Extension text box. Click Ok button.

Do the same on all domains which you allow Perl support. If you allow Perl for all domains, process points 1-7 on parent item "Web Sites". All new websites will inherit these settings. IIS will ask whether to apply changes on existing sites.
We did this and can get .pl and .cgi scripts to work in the cgi-bin. We have a few customers who dont want their scripts inside the cgi-bin. The weird thing is .pl files will work, but .cgi files dont. Any ideas?
 
Back
Top