THE IT IDEAS

  • Home

Wednesday, 3 December 2014

How to Create VirtualHost in Apache 2.4

 THE IT IDEAS     10:53     apache2   

Install Apache2 with below command.

#sudo apt-get install Apache2

Create Demo VirtualHost Directory

#sudo mkdir -p /var/www/html/example.com
#sudo mkdir -p /var/www/html/theitideas.com

Create Demo Pages for Each Virtual Host

#nano /var/www/html/example.com/index.html

Paste Below code in index.html file

<html>
  <head>
    <title>Welcome to Example.com!</title>
  </head>
  <body>
    <h1>It works!  Example.com</h1>
  </body>
</html>

Save the file and exit.

Now for theitideas.com

#nano /var/www/html/theitideas.com/index.html

Paste Below code in index.html file

<html>
  <head>
    <title>Welcome to theitideas.com!</title>
  </head>
  <body>
    <h1>It works!  theitideas.com</h1>
  </body>
</html>

Save the file and exit.



Now Create the First Virtual Host File

#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

Edit the file with below command and edit file as mentioned below.

#sudo nano /etc/apache2/sites-available/example.com.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/html/example.com
</VirtualHost>

Again to the same process for theitideas.com VH.

#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/theitideas.com.conf

Edit the file with below command and edit file as mentioned below.

#sudo nano /etc/apache2/sites-available/theitideas.com.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName theitideas.com
        ServerAlias www.theitideas.com
        DocumentRoot /var/www/html/theitideas.com
</VirtualHost>


Now Turn to enable both Virtual Host 

#sudo a2ensite theitideas.com.conf
#sudo a2ensite theitideas.com.conf

Restart Apache Service

#sudo service apache2 restart
or
#sudo /etc/init.d/apache2 restart

Virtual Host is set in apache server. Now you have to make changes in your machine to check Virtual Machine.

#sudo nano /etc/hosts

Add line in you hosts file.

your IP example.com
your IP theitideas.com

e.g. 
192.168.0.101  example.com
192.168.0.101  theitideas.com


Save and exit. Now Open your browser and open example.com and theitideas.com

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook

Related Posts:

  • How to run a simple PHP web server # php -S localhost:8000 -t /path/to/folder/directory Above command give output like below PHP 5.6.4-4ubuntu6 Development Server started at Thu Apr… Read More
  • How to change DocumentRoot path in Apache Ubuntu 14.04 LTS Make backup copy of Apache default file with below command #sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-d… Read More
  • How to Create VirtualHost in Apache 2.4 Install Apache2 with below command. #sudo apt-get install Apache2 Create Demo VirtualHost Directory #sudo mkdir -p /var/www/html/example.com #sudo… Read More
  • How to redirect HTTP to HTTPS First you need to install SSL Certificate Successfully. Once your done that choose any of example to do redirect url. Example : 1 In this example … Read More
  • Install MongoDB php driver in XAMPP/LAMPP To install the php driver for MongoDB Prerequisite :: #sudo apt-get install autoconf #export PHP_AUTOCONF=/usr/bin/autoconf #sudo apt-get install g… Read More
Newer Post Older Post Home

Like Us !!!

Recent Posts

Blog Archive

  • ►  2016 (1)
    • ►  April (1)
  • ►  2015 (12)
    • ►  August (1)
    • ►  May (2)
    • ►  April (8)
    • ►  March (1)
  • ▼  2014 (23)
    • ▼  December (8)
      • How to resolve mcrypt extension missing error.
      • How to upload EC2 Data to S3 Bucket with s3cmd
      • How to move github local folder to another location.
      • Basic GitHub Commands
      • Installation and configuration of GeoIP module in php
      • Install MongoDB php driver in XAMPP/LAMPP
      • How to redirect HTTP to HTTPS
      • How to Create VirtualHost in Apache 2.4
    • ►  November (12)
    • ►  April (2)
    • ►  March (1)
  • ►  2013 (7)
    • ►  December (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (3)
  • ►  2012 (15)
    • ►  December (6)
    • ►  November (9)

Categories

apache2 EC2 error mysql php ubuntu aws aws rds browser github installation linux mount s3 AWS Bucket CentOS Computer DocumentRoot change How to Benchmarking Webserver IP LAMP Restart Computer SCP command SQL SERVER XRDP administrator amazon rds backup basic commands chat command line disable download drupal ec2.chroot environment external storage device fstab functions geoip gmail google home page iis instance internet java mod rewrite mongodb multiple login network password one password php5 php5-fpm php7 private browsing python repair filesystem repo reset password rhel sa password same computer script sftp share skype ssh tomcat ubuntu 16.04 ubuntu16 visudo windows 8 youtube
JobsMagBlogJobsMag.InThingsGuide

Popular Posts

  • How to Install PHP 7.0, Apache 2.4.18, & MySQL 5.7 on Ubuntu 16.04 LTS
    Update your repo list with below command $ sudo apt-get update -- > Install Apache 2.4.18 $ sudo apt-get install apac...
  • How to Use Python ‘SimpleHTTPServer’ to Serve Files Instantly
    How to Use Python ‘SimpleHTTPServer’ to Serve Files Instantly first check is python available or not. #python –V If command return version...
  • How to setup Network Configuration in Ubuntu Server 14.04
    Open Network Configuration file. #nano /etc/network/interface Then Add below mentioned lines and make changes as per your need. auto eth0 i...

Copyright © 2025 THE IT IDEAS | Powered by Blogger