Whenever possible place any executable scripts inside the cgi-bin directory.
When uploading scripts via FTP make sure to always use ASCII mode. If you are doing a server to server FTP transfer use BINARY mode.
The first line in all PERL scripts must contain the path to PERL which is: #!/usr/bin/perl
Directories and scripts should both executable. Usually the permission level 755 is the best. All files and directories where CGI will be executed must NOT be world or group writeable and must be at least user executable.
Data files that scripts will read/write must NOT be group or world writeable.
Make sure that you DO NOT modify the permissions of the cgi-bin itself. This will cause all scripts to fail. If the permissions have be altered, chmod the cgi-bin back to 755.
Check the code. Frequently there may be a line not closed with “;” or a routine that is not closed.
Make sure that all modules and ‘include files’ required by the scripts are located on the server and are in the proper locations.
Check that your CGI/Perl script is outputting the necessary HTTP headers. To do that in Perl, just below the “shebang” line (#!/usr/bin/perl), type the following line.
#!/usr/bin/perl
print "Content-type: text/html\n\n"
Add a “-w” to the first line of your script. (Example: # !/usr/bin/perl
Most FTP programs allow you to change the permissions of files on the server. You may also use the command shell (SSH) and use the command directly. Example: chmod 755 myscript.cgi
Running CGI scripts in the httpdocs directory without mod_perl in Plesk
To accomplish this on a per domain basis you will need to create a vhost.conf in the conf directory at /var/www/vhosts/serverbuddies.com/ with the following code.
<Directory /var/www/vhosts/mt-example.com/httpdocs>
<Files ~ (\.cgi$)>
SetHandler cgi-script
Options ExecCGI
allow from all
</Files>
</Directory>
Then run the following command to enable the change.
/usr/local/psa/admin/sbin/websrvmng -v -a
Now, all files with ‘.cgi’ extension will be executed as usual CGI scripts in /cgi-bin/.
To enable CGI in httpdocs for the whole server just uncomment the “AddHandler cgi-script .cgi” directive in httpd.conf and restart Apache.
Reference: http://parallels.com/
Safety net for Perl
Perl by default is very forgiving. In order to make it more robust it is recommended to start every program with the following lines:
#!/usr/bin/perl
use strict;
use warnings;
The two additional lines request from perl to catch various common problems in your code. They check different things so you need both. A potential problem caught by use strict; will cause your code to stop immediately when it is encountered, while use warnings; will merely give a warning (like the command-line switch -w) and let your code run.
To read more about them check their respective manual pages at strict and warnings.
How do I enable cgi-scripts to run from both httpdocs and httpsdocs directories in Plesk?
By default Plesk runs CGI scripts in /cgi-bin/ folder only. To allow CGI scripts be processed from any folder, you should uncomment the cgi-script AddHandler directive in the main apache configuration file /etc/httpd/conf/httpd.conf
AddHandler cgi-script .cgi
Then restart Apache with the following command:
/etc/rc.d/init.d/httpd restart
Such customizations can also be done on a per domain basis in vhost.conf.
Creating a wildcard SSL certificate in Plesk
A wildcard DNS record is a record in a DNS zone that will match requests for non-existent domain names. A wildcard DNS record is specified by using a “*” as the left most label (part) of a domain name, e.g. *.example.com.
A wildcard DNS record in a zone file looks similar to this example:
*.serverbuddies.com. 3600 IN MX 10 host1.serverbuddies.com.
This wildcard DNS record will cause DNS lookups on domain names ending in example.com that do not exist to have MX records synthesized for them. So, a lookup for the MX record for somerandomname.example.com would return an MX record pointing to host1.example.com.
Since version 8.0.1 Plesk allows to create and use certificates for Wildcard domain names (like *.serverbuddies.com.com).
Wildcard certificate can be created the same way that usual certificate is generated. The only difference that you specify the name with “*” sign in the left path, for example *.serverbuddies.com” domain name in the Wildcard certificate will match all this domain’s subdomains, like mail.serverbuddies.com, ftp.serverbuddies.com, etc