hosting

If the reseller is selling Web Hosting

Debugging Perl/CGI Scripts

Hosting servers are configured to store error logs for CGI/Perl scripts, encountered during the course of operation. By default, error messages are sent to STDERR.

Most HTTPD servers direct STDERR to the server's error log, which stores information for all the websites hosted on a shared hosting environment. As this, this file cannot be accessed by individual website owners. You may wish to keep private error logs, distinct from the server's error log, or may wish to direct error messages to to a web browser.

This can be accomplished by coding your scripts accordingly during the development phase.

Sending error messages to a private log file

The carpout() function can be used to achieve this. Since carpout() is not exported by default, you must import it explicitly as -


use CGI::Carp qw(carpout);

The carpout() function requires one argument, which should be a reference to an open filehandle for writing errors. It should be called in a BEGIN block at the top of the CGI application so that compiler errors will be caught.

Example:


BEGIN {
use CGI::Carp qw(carpout);
open(LOG, ">>/domains/domain.com/logs/cgi-error.log") or
die("Unable to open cgi-error.log: $!\n");
carpout(LOG);
}

carpout() does not handle file locking on the log for you at this point.

Sending error messages to a Web Browser

Fatal (die, confess) errors can be sent to a web browser by importing the special "fatalsToBrowser" subroutine:


use CGI::Carp qw(fatalsToBrowser);
die "Couldn't open log file";

Fatal errors will now be echoed to the browser as well as to the log file. CGI::Carp arranges to send a minimal HTTP header to the browser so that even errors that occur in the early compile phase will be seen. Nonfatal errors will still be directed to the log file only (unless redirected with carpout).

 


Sample Script

#!/usr/bin/perl -wT

# In the first line above, T causes Perl to check

# for "tainted" data, that is, data from outside the
# script (i.e. user input) that is going to be used
# to affect something else outside the script
# (i.e. writing to a log file)

# You can untaint data by parsing it for unwanted
# characters then saving it to another variable.

# If you are having trouble with a script, try removing

# the T switch to see if that is the problem.

# The w switch in the first line causes warnings about
# script syntax to be printed, if there are any.

# This script does 2 things:
#
#1. It directs fatal errors to the browser,
# so when the script is invoked via the Web,
# a meaningful error message is returned.
# This is useful when developing a script;
# but should be disabled when the script
# is made publicly available.
#
# 2. It will direct any error message the script
# generates to an error log that resides in
# the user's home directory. The file must
# already exist and be "other" writeable.

# Notice that the following is enclosed in
a BEGIN { }
# block that causes it to execute before the rest of
# the script is read.

# This block should be placed in the main script,
# as near the top as practical. Do not place it in
# subroutines or libraries. Always test
# subroutines thoroughly before placing them
# in libraries.

BEGIN {

# define an error log in YOUR home directory
# this is an example where the
# home directory is /domains/domain.com/

my $error_log = "/domains/domain.com/logs/cgi-error.log";

# "my" in the line above makes the variable
$error_log
# local so it only has meaning inside this block.
# See your text for more on variable scope.

# load the CGI::Carp module;
# fatalsToBrowser directs fatal errors to the browser
# carpout is for directing errors to the error log

use CGI::Carp qw(fatalsToBrowser carpout);

open (LOG,">>$error_log") ||
die "couldn't open log file: $!";
carpout(LOG);

# open(...) is used to open a file.
# >> means the new input will be appended what's
# already in the file.

# LOG is a nickname (properly called a
"file handle")
# that is given to the file so it is easy to refer to
# it later, i.e. carpout(LOG) sends the error
# message to the file with the nickname LOG

# || means "or" (as in do this or that)
# die means stop executing the program. You can add
# a message in quotes after the die command.

# $! is a special variable that contains
the current error info

}

# The following line will cause an error.
# It is a call to a sub-routine that does not exist.
# After you have tried this script and received the error message,
# comment out the following line so no error occurs
# and "Hello world!" is printed.

&non_existent_subroutine();

print <<EOT;
Content-type: text/html\n\n

<HTML>
<BODY>
Hello world!
EOT

print "</BODY></HTML>";

Adding Domain Aliases

Additional domain names can be pointed to your website hosted on either a cPanel Linux or a Plesk Windows Hosting package.

Parked Domains under cPanel See details

Domain Aliases under Plesk See details

Additional Information
  • For each Domain Alias that you submit, you would need to point this aliased domain name to your primary domain name (for which you have bought Hosting).

    This can be accomplished by either one of these ways:

    1. Option 1:

      On the existing Name Servers of the Domain Alias, create 2 Address Records (A Records) pointing to your primary domain name. The Address Records can be viewed by clicking the Name Server Details link within the Order Details view page of the Web Hosting Order. Notice the first 2 Address Records and request your current DNS Service Provider to replicate them for your alias domain name.

    2. Option 2:

      If you have registered the alias domain name through and your current DNS Service Provider does not allow you to create these Records, then you can follow the process listed below:

      1. Search for the domain name for which you have purchased the Web Hosting package and go to the Order Details view. See details

      2. Click the Name Server Details link and note the first 2 Address Records.

      3. Replicate these Address Records for the alias domain name that you wish to add to your Web Hosting Order, from within the DNS Management Console of the alias domain name. See details

Domain Alias

'

allows you to point multiple domain names to your Web Hosting package. This enables you to have your website running on multiple domain names, without having to go to the trouble of setting up the site for each domain name.

This feature is referred as Domain Alias on our Plesk Windows Hosting servers and Parked Domain on cPanel Linux Hosting servers.

Note
  • You can add up to 10 Domain Aliases / Parked Domains for your cPanel Linux Hosting package that you purchase from .

    There is no such limitation on a Plesk Windows Hosting package.

  • For each Domain Alias / Parked Domain that you add to your Web Hosting package, you need to also add DNS Address Records to point it to your primary domain name. See details

Example:

If you have bought a Windows Web Hosting package for yourdomain.com and want to point yourdomain.net and yourdomain.info to the same website, then you may do so by mentioning yourdomain.net and yourdomain.info as aliases for yourdomain.com.

Installing your Intermediate CA Certificate or CA Bundle

Note

The below mentioned process can be performed only after you have enabled SSL (Dedicated IP) support for your
website. See details

To install an Intermediate CA Certificate or CA Bundle on your cPanel Linux Web Hosting Package

  1. Login to your Control Panel, Search for the domain name for which you have purchased this cPanel Linux Hosting Order and go to the
    Order Information view. See details

  2. Click the Manage Web Hosting link.

  3. Click the SSL/TLS Manager button under Security.

  4. Click the Setup a SSL certificate to work with your site. link under Activate SSL on Your Web Site (HTTPS).

  5. Select the Domain for which you have a digital certificate.

  6. If you have already installed your digital certificate, mention the Intermediate CA Certificate or CA Bundle within the Ca Bundle (CABUNDLE) textbox.
    Alternatively, you may paste your digital certificate along with your Intermediate CA Certificate or CA Bundle in their respective text boxes.

    Note

    If you have purchased a Digital Certificate through , then you need to install the
    thawte Cross Root CA and Intermediate CA
    together as a CA Bundle. See details

To install an Intermediate CA Certificate or CA Bundle on your Plesk Windows Web Hosting Package

  1. Login to your Control Panel, Search for the domain name for which you have purchased this Plesk Windows Hosting Order and go to the
    Order Information view. See details

  2. Click the Manage Web Hosting link.

  3. In your Plesk Panel, click on SSL Certificates under the Additional Tools section.

  4. Click the Add SSL Certificate link under Tools.

  5. If you have already installed your digital certificate, browse to upload your CA Certificate and click Send File. Alternatively, you may paste
    your CA Certificate along with the Private key (CSR) and Certificate in their respective text boxes and click Send Text.
    See details

    Note

    If you have purchased a Digital Certificate through , then you need to install
    the thawte Cross Root CA and Intermediate CA
    together as a CA Bundle. See details

Uninstalling your Digital Certificate

You can uninstall a Digital Certificate from within your Control Panel provided by .

To Uninstall a Digital Certificate

cPanel Linux Web Hosting Packages

If you have purchased a cPanel Linux Web Hosting package with , then follow the below mentioned process:

  1. Login to your Control Panel, Search for the domain name for which you have purchased this Hosting Order and go to the
    Order Information view. See details

  2. Click the Manage Web Hosting link.

  3. Click the SSL/TLS Manager under Security. See details

Plesk Windows Web Hosting Packages See details

Generating a Self-signed Certificate

Note

The below mentioned process can be performed only after you have enabled SSL (Dedicated IP) Support for your website.

You can generate a Self-signed Certificate from within your Control Panel provided by .

To Generate a Self-signed Certificate

cPanel Linux Web Hosting Packages

If you have purchased a cPanel Linux Web Hosting package with , then follow the below mentioned process:

  1. Login to your Control Panel, Search for the domain name for which you have purchased this Hosting Order and go to the
    Order Information view. See details

  2. Click the Manage Web Hosting link.

  3. Click the SSL/TLS Manager under Security. See details

Plesk Windows Web Hosting Packages See details