Hosting your websites

This article will help you to setup the hosts, in case you want to run multiple websites on your VPS. This is similar to setting up a shared server that hosts multiple websites, using a single shared IP Address.

  • This documentation assumes you've already installed the LAMP stack on your VPS. If you haven't done that yet, refer to the LAMP installation guide.

    Additional Information

    Getting your VPS LAMP ready

  • Ensure that you are connected to the server using an SSH client as a root user.

  • Website management becomes easier through cPanel or Plesk. If you have installed any of these panels, you need not follow this documentation.

Hosts Setup

The process to host a single website is different from hosting multiple sites.

To Host a Single Website

If you want to host only one domain name in the VPS, then all you need to do is point your domain name to the IP Address of the VPS. This can be done by simply adding an A record for the domain name from the DNS interface of the VPS.

By default, the document root of your server is /var/www/html. You can upload the contents of your site in this directory. The website can also be accessed using the IP Address of the VPS.

To Host Multiple Websites

If you want to host multiple domain names in the same VPS, then you would be required to create a virtual host entry in your Apache configuration file. Refer to the steps mentioned below.

  1. Assume you want to host the websites for domain names and You'll first have to create directories for each website under /var/www/html. You can create the directories from Plesk Power Panel's - File Manager or via SSH. The steps given below are using the Command Line Interface.

    Navigate to the directory /var/www/html.

    cd /var/www/html

    Create the directories for each website.


    The directories will be created as below.

    Creating Directories

  2. Open the Apache configuration file by using the command:

    vi /etc/httpd/conf/httpd.conf

    Scroll down to the end of this file, uncomment the lines and add your domain names as shown below.

    Editing Apache Configuration File

    The various paramaters in Name based Virtual Hosting are:

    • NameVirtualHost: Designates an IP address for Name based Virtual Hosting

    • <VirtualHost>: Contains directives that apply only to a specific hostname or IP Address

    • ServerAdmin: Email address that the Server includes in error messages sent to the client

    • DocumentRoot: This directive sets the directory from which httpd will serve files for this host

    • ServerName: Used to uniquely identify the Virtual Host; FQDN (Fully Qualified Domain Name) format to be used

    • ServerAlias: This directive is used to set the alternate names for the host

    • ErrorLog: Location where the Server will log errors for this host

    Additional Information

    If you want to learn more about Virtual Hosts or customize them further, you may refer to the Apache Virtual Host documentation.

  3. For the configuration changes to take effect, you need to restart the Apache service using the command:

    service httpd restart

  4. To check how these sites will resolve or to test their functioning, you can add sample html files.

    Create the index.html files for and

    vi /var/www/html/

  5. In order to access the websites prior to setting up their DNS zones, you can edit your local computer's hosts file.

    Additional Information

    Modifying the hosts file

    For actual resolution over the Internet, create A records for each domain name pointing to the IP Address of the VPS, in their respective DNS zones.

Uploading Content through FTP

You can upload the content using any FTP client of your choice using the below details:

  • Host: <Your_VPS_IP_Address>

  • Username: root

  • Password: Password for the root user (same as your VPS password)

  • FTP Type: SFTP

  • Port: 22

This is a complete setup with minimal configuration. You can customize or secure your website further as per your needs.