•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

Hosting 2 websites on one server

  • Home
  • Client
  • Qa Forum
  • Hosting 2 websites on one server

Posted By: Simon | 1 Replies | Last Reply On: Nov 02, 2017 13:00:27

I have your dedicated server and wondering how can i go about hosting two websites on a single server? 
 

Psychz - Nikhil

Votes: 0Posted On: Nov 02, 2017 13:00:27
 

Hi! 

You can certainly host multiple websites on your dedicated server. We can achieve this with the help of Apache2 web server. Apache2 web server is one of the most popular web servers today. With the help of Apache2 web server, you can host multiple websites on a single IP address. In this case, we will be operating on Ubuntu 14.04 operating system.

We will be creating two websites abc.com and xyz.com websites and hosting them on the server.


PREREQUISITES

1. Active network connection
2. Ubuntu Operating System
3. Apache2 Web server


Apache2 Installation

Run the following command to install Apache2 web server.

sudo apt-get install apache2


Making Separate directories for websites

We will now make separate directories for the websites we are planning to create. Please run the following command to create the directories on the "/var/www" location.

sudo mkdir -p /var/www/abc.com/html/
sudo mkdir -p /var/www/xyz.com/html/


Grant Permissions

The directory "/var/www" can only be accessed by users with special permissions. We need to grant Apache2 these permissions so that it can manage and edit the files.

Please run the following command to achieve the same.

sudo chown -R www-data:www-data /var/www/
sudo chmod -R 755 /var/www/


Creating Web pages

Now we will create a simple web page in the directories that we created earlier (/var/www/abc.com/html/).

sudo vi /var/www/abc.com/html/index.html
sudo vi /var/www/xyz.com/html/index.html

 

As these two directories will create separate websites, the web pages created on file index.html will be displayed on these websites.
Just a test case, we will display the simplest of web page. You can create the web page as per your requirement.


  #
  #
  # abc.com
  #
  #
  #

This is abc.com
  #


  #
  #  

You can do the same for "xyz.com".


Virtual Host File Creation

After the Apache2 web server is installed, the apche2 directory is created in "/etc". In this folder, a default host file "000-default.conf" is created which can be used as a reference for creating our virtual host file. This file contains the configuration of our virtual hosts.

In this case, we will copy the default host file and name it as "abc.com.conf" and "xyz.com.conf".

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/abc.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/xyz.com.conf


Please edit the host file as below.

sudo vi /etc/apache2/sites-available/abc.com.conf

 


 #
 # ServerAdmin admin@abc.com
 # ServerName abc.com
 # ServerAlias www.abc.com
 # DocumentRoot /var/www/abc.com/html
 #

You can also add fields such as Error Log and Custom Log.


Edit the "xyz.com.conf" file in the same way we have edited the file above. 


The next step is to enable the site with the help of the following command.

sudo a2ensite abc.com.conf
sudo a2ensite xyz.com.conf


Restart the Apache2 server

Please restart the web server to save the changes.

sudo service apache2 reload


You will notice that the sites will be displayed in the "/etc/apache2/sites-enabled" folder.


Local Host file Configuration

The last step is to map the IP address of the system to the websites in the local host file. In Ubuntu operating system, the local host file is "/etc/hosts".


127.0.0.1 localhost
192.168.0.6 abc.com
192.168.0.6 xyz.com


Please open your browser and type the domain name of the websites. The web page that you have created will be displayed.

 

 

 

 

 


 

 


  

Was this reply helpful?

Related topics

  • What is Web Hosting?
  • What Is Dedicated Hosting And How To Pick A Provider?
  • Learn About Colocation Benefits And How To Get Started
  • Colocation Vs Managed Hosting
  • SSL Certificate Without Dedicated IP
  • Cloud Hosting or Dedicated Server
  • How can I load balance website with the CDN?
  • Best Dedicated Server Hosting in Europe
  • Web Hosting vs Dedicated Sever
  • The Difference Between Brotli And Gzip Compression Algorithms To Speed Up Your Site
  • CDN Hosting and why Every website should utilize a CDN
  • Tutanota "blocking" on Comcast Network sparks the debate of net neutrality again
  • Cloud Hosting vs. Dedicated Server - How Do You Choose?
  • History of Internet
  • CDN and Load Balancer: Ultimate combination for efficient content delivery
Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2023 Psychz Networks, A Profuse Solutions Inc Company