singledomainhostinglinuxuk

Single Domain Hosting Linux UK

How do I set the default page?

When a hosting order is purchased, a default index.html page is uploaded to the hosting. You may rename or delete this default file after uploading your website content, so that your website resolves without any issues.

You may manually set the default page for your website by following these steps.

Linux Hosting

The default file can be specified using the .htaccess file.

Example:

If "Homepage.html" is the default page for your domain then you can add the below line to the .htaccess file.

DirectoryIndex Homepage.html

Windows Hosting

You can follow these steps to set the default page from your Plesk panel

  1. Login to the Plesk panel of the domain name for which you wish to set the default page.

  2. Click the Virtual Directories link.

  3. Under the Tools section, click the Directory Properties button.

  4. Under Documents, set the required default page by moving it to the top and click the OK button.

PHP Script to Test MySQL Database Connectivity

Provided below is a simple PHP script to test MySQL database connectivity. The result of this script displays the names of the tables present within the specified database.

Sample Script



$connect=mysql_connect("dbserver","dbuser","dbpassword") or die("Unable to Connect");
mysql_select_db("dbname") or die("Could not open the db");
$showtablequery="SHOW TABLES FROM dbname";
$query_result=mysql_query($showtablequery);
while($showtablerow = mysql_fetch_array($query_result))
{
echo $showtablerow[0]." ";
}
?>

Explanation about the variables used in the script:

  • dbserver: Mention the value as localhost for Linux Hosting (cPanel). For Windows Hosting (Plesk), MySQL Server IP needs to be mentioned.

  • dbname: Specify complete database name including the prefix. For example, reseloaq_mysql.

  • dbuser: Mention the database user associated with the database.

  • dbpassword: Mention the password for the above database user.

SSH Access

What is Secure Shell (SSH)?

Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote shell services or command execution and other secure network services between two networked computers that connects, via a secure channel over an insecure network, a server and a client (running SSH server and SSH client programs, respectively). SSH is typically used to log into a remote machine and execute commands. It can transfer files using the associated SSH file transfer (SFTP) or secure copy (SCP) protocols. The standard port used to connect through SSH is 22.

Enabling SSH Access

supports SSH access on all its Linux (Single Domain, Multi Domain and Reseller) Hosting Servers. SSH connection to 's Linux Hosting Servers can be through key or password based authentication.

Connecting to a Server through SSH using Password authentication

For Linux:

  1. Run the below command:

    ssh -l user remote-server
  2. Enter the cPanel password.

For Windows:

  1. Open Putty and enter the Remote Host Name or IP Address.

  2. Click Open and enter the cPanel username and password.

Connecting to a Server through SSH using Key based authentication

Generating a SSH Key Pair

You can generate the key pair (public key and private key) from the cPanel or your local computer.

cPanel

  1. Login to the cPanel of the domain for which you wish to generate the key pair.

  2. Click on SSH Shell Access under the Security section.

  3. Click on Manage SSH Keys.

  4. Click on Generate a New Key.

  5. Enter the key name and password and click on Generate Key.

Note

The private key needs to be stored on your local computer.

  • For Linux, copy the key file to your ~/.ssh folder.
  • For Windows, save the key file to a safe location.

Local Computer

For Linux:

Run the below command:

ssh-keygen -t dsa

OR

ssh-keygen -t rsa

The output would be similar to:

Generating public/private dsa key pair. 
Enter file in which to save the key (~/.ssh/id_dsa): Press [Enter] key 
Enter passphrase (empty for no passphrase): Press [Enter] key 
Enter same passphrase again: Press [Enter] key 
Your identification has been saved in ~/.ssh/id_dsa 
Your public key has been saved in ~/.ssh/id_dsa.pub 
The key fingerprint is: 
<some string>
		

OR

Generating public/private dsa key pair. 
Enter file in which to save the key (~/.ssh/id_dsa): Press [Enter] key 
Enter passphrase (empty for no passphrase): Press [Enter] key 
Enter same passphrase again: Press [Enter] key 
Your identification has been saved in ~/.ssh/id_dsa 
Your public key has been saved in ~/.ssh/id_dsa.pub 
The key fingerprint is: 
<some string>
		

id_dsa or id_rsa is the private key and id_dsa.pub or id_rsa.pub is the public key.

For Windows:

  1. Download PuTTY.

  2. Download PuTTYgen.

  3. Open PuTTYgen.

  4. Select the SSH-2 RSA (or SSH-2 DSA) option and click the Generate button.

  5. Move mouse randomly over the empty space below the progress bar to create some randomness in the generated key.

  6. Click the Save private Key button, without providing any passphrase.

  7. Click Yes on the window asking for confirmation for saving the key without a password.

  8. Save the key file with an appropriate name, say ssh_private_key.ppk.

  9. Upload the public key to the hosting server from the cPanel, using the Import Key option

Authorize the SSH Server to use the Public Key

  1. Click on Manage Authorization for the key you wish to authorize.

  2. Click on Authorize to authorize the key.

  3. Or Deauthorize to deauthorize it.

Accessing the Remote Server

For Linux:

Run the below command:

ssh -l user remote-server

For Windows:

  1. Open Putty and enter the Remote Host Name or IP Address.

  2. In the left menu, click Data under Connection and enter the cPanel username in the Auto-login username field.

  3. In the left menu, click Auth under Connection -> SSH and enter the path of the saved private key file.

  4. Click the Open button to connect to the server.

Perl-based Form Mail (Feedback) Script

Using a Perl script, you may accept feedback from your website visitors and get the results emailed to you. You can use the sample script provided by and tweak it a bit to suit your requirements.

Sample Script


#!/usr/bin/perl
print "Content-type: text/html\n\n";
#
$title='Perl Mail demo';
$to='TO_Email';
$from= '[email protected]';
$subject='perl mail';

open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message
mail body text here\n";

close(MAIL);

print "

$title\n\n\n";

print "

$title

A message has been sent from $from to $to

";
#

Note
  • The .pl file containing the script needs to be uploaded to your web server in ASCII mode only.

  • The .pl file needs to have execute permissions for the normal web user. For example, the .pl file can have permissions 755 or 765.

Sample HTML Feedback Form

The following code needs to be added in the form which connects to the above script:

Below is the explanation about the variables in the code:

  • recipient: This would be the email address, where the email containing the data submitted through the form needs to be delivered.

  • email: You would need to change the email address in the email field to any email address on the domain name, on which you are incorporating this script. For example, if you are deploying this script on yourdomain.com, then you would define the From email address as [email protected]. This email address need not be existing on the Mail Server of yourdomain.com; however, the domain name in the email field has to be yours. This implies that you may use an email address such as [email protected]. This email address will appear as the From email address in the email sent by the script.

  • realname: The value here indicates the name mentioned in the From section of the email, that will be sent upon submission of this form. This can be modified as per your requirement.

  • subject:The value in this field can be changed to indicate an appropriate subject for the mail to be sent. For example, you may set this as YourDomain.com Feedback Form or any other subject that would allow you to uniquely identify from which form on your website this data has been received.

  • redirect: Once the visitor provides feedback, he/she can then be redirected to another page on your website. In order to achieve this, you need to mention the path to the HTML file in the redirect field. Alternately, you can display a message to the visitor thanking him/her for the feedback. Such messages can be displayed in a new page like thanks.htm. Such a page can also contain other information as deemed necessary.

Note

In an attempt to keep a check on abuse from 's Hosting Servers, the following conditions have been set for mail scripts on 's Linux Hosting Servers:

  • The domain name in either the To or the From email address used in the script should be your domain name hosted with .

    Example: yourdomain.com is hosted with and yourotherdomain1.com and yourotherdomain2.com are hosted with some other hosting provider.

  • For mail scripts with the From email address as <user>@<server_hostname>, the To email address compulsorily should be an email address on your domain name hosted with
    .

    Example: yourdomain.com is hosted with with parent user yourdo & server name cp-00.webhostbox.net and yourotherdomain1.com is hosted with some other hosting provider.

    With the From email address as [email protected]:

PHP-based Form Mail (Feedback) Script

Using a PHP script, you may accept feedback from your website visitors and get the results emailed to you. You can use the sample script provided
by and tweak it a bit to suit your requirements.

You would need to change the email address in the field $from to any email address on the domain name on which you are incorporating this script.

Example:

If your domain name is yourdomain.com, then you would define the From email address as [email protected].

This email address need not be existing on the mail server of yourdomain.com; however, the domain name in the $from field has to be yours.

You may use an email address such as [email protected].

The value in the $mailto field needs to be changed to the email address, where the email containing the data submitted through the form needs to be delivered.

Note

In an attempt to keep a check on abuse from 's Hosting Servers, the following conditions have been set for mail scripts on 's Linux Hosting Servers:

  • The domain name in either the To or the From email address used in the script should be your domain name hosted with .

    Example: yourdomain.com is hosted with and yourotherdomain1.com and yourotherdomain2.com are hosted with some other hosting provider.

  • For mail scripts with the From email address as <user>@<server_hostname>, the To email address compulsorily should be an email address on your domain name hosted with
    .

    Example: yourdomain.com is hosted with with parent user yourdo & server name cp-00.webhostbox.net and yourotherdomain1.com is hosted with some other hosting provider.

    With the From email address as [email protected]:

Once the visitor provides feedback, you can display a message to the visitor thanking them for their feedback.

Sample Script


$mailto="[email protected]";
$pcount=0;
$gcount=0;
$subject = "Mail from Enquiry Form";

$from="[email protected]";
while (list($key,$val)=each($_POST))
{
$pstr = $pstr."$key : $val \n ";
++$pcount;

}
while (list($key,$val)=each($_GET))
{
$gstr = $gstr."$key : $val \n ";
++$gcount;

}
if ($pcount > $gcount)
{
$message_body=$pstr;
mail($mailto,$subject,$message_body,"From:".$from);
echo "Mail has been sent";
}
else
{
$message_body=$gstr;
mail($mailto,$subject,$message_body,"From:".$from);
echo "Mail has been sent";
}
?>