How-to Create an Apache 2 Virtual Host on Debian 7 Wheezy Linux Quick-Start Guide

October 14th, 2014 by thelinuxevangelist

Debian Apache 2 Virtual Hosts Quick-Start



The Tutorial Shows You Step-by-Step How-to Getting-Started with Apache 2 Virtual Host on Linux Debian 7 Wheezy i386/amd64 Desktop/Server.

The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine.

Virtual Hosts can be:

  • Name-based“, meaning that you have multiple names running on each IP address
  • IP-based“, meaning that you have a different IP address for every web site

The fact that they are running on the same physical server is not apparent to the end user.

Create Apache 2 Virtual Host on Debian 7 Wheezy - Featured

How-to Create a Name-based Virtual Host on Linux Debian

    How-to Install LAMP Server on Debian

    LAMP Server Installation Debian
  1. Or Open a Command Line Terminal Window
    (Press “Enter” to Execute Commands)

    Create Apache 2 Virtual Host on Linux Debian 7 Wheezy - Open Terminal

    Or Login into Server Shell.

  2. Add the Domain to the Host Config File

    su 

    If Got “User is Not in Sudoers file” then Look: Solution

    nano /etc/hosts

    Append:

    127.0.0.1	[myDomainName.com]
    

    Only Substitute Your real Domain Name to “[myDomainName.com]” :)
    Ctrl+Shift+v to Paste Content into nano
    Ctrl+x to Save and Exit from nano Editor

  3. Create the VHost Target Directory

    mkdir /var/www/html/[mySite]

    And may be also a Testing index.html:

    echo "

    The New Web-Site is Working on Apache2!

    " >> /var/www/html/[mySite]/index.html

    Then Set the Web Server User Permission…

    chown -R www-data:www-data /var/www/html/[mySite]
  4. Create a VHost Config File

    nano /etc/apache2/sites-available/[myDomainName].conf

    Append at Least:

    <VirtualHost *:80>	
    	ServerName	[myDomainName.com]
    	ServerAlias	www.[myDomainName.com]
    	DocumentRoot /var/www/html/[mySite]
    </VirtualHost>
    

    To get a little More Insight may look:

    cat /etc/apache2/sites-available/000-default.conf
  5. Enabling the New Virtual-Host

    cd /etc/apache2/sites-enabled
    ln -s ../sites-available/[myDomainName].conf .
  6. Restart Apache2 Web Server

    service apache2 restart
    exit
  7. How-to Enable Apache2 mod_rewrite Module on Debian

    Enabling Apache2 Rewrite for Debian

    How-to Create a IP-based Virtual Host on Linux Debian

    How-to Create an IP-Based Virtual Host on Debian:

    Debian Apache2 IP Virtual-Host
Share on Tumblr

Tags: , , , , , , , , , ,


Comments are disabled