X

How To Create Virtual Host On Apache Web Server Using Ubuntu 14.04

The Apache Soft is a powerful open source web server.  The Apache web server already uses cpanel and many more server. Now is popular to think name based virtual host. It’s provide from Apache web server.  So I configure step by step name based virtual host on your server.

How To Install Mysql Server on Ubuntu 14.04
How To Install mysql Community on Windows 10

Name based virtual host requirements: Ready one Ubuntu 14.04 machine

  • Create one machine
  • RAM : 1 GB
  • Ethernet port : 1
  • CPU : 2

Step :#01: You new machine update and upgrade command below:

root@Virtual-Machine:~# apt-get update && apt-get upgrade -y

After few minutes wait for upgrade then install Apache web server command

root@Virtual-Machine:~# apt-get install apache2 apache2-utils php5 libapache2-mod-php5 php5-mcrypt

Step #02: When installation complete then goto directory for setup virtual host

root@Virtual-Machine:~# cd /etc/apache2/sites-available/

Step #03: Create or open tech1.conf file for site one. File create command touch tech1.conf

root@Virtual-Machine:/etc/apache2/sites-available# vi tech1.conf

Insert below all line into tech1.conf file.

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerAlias tech1
DocumentRoot /var/www/html/tech1/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Step #04: Create another tech2.conf file

root@Virtual-Machine:/etc/apache2/sites-available# vi tech2.conf

Insert below all line into tech2.conf file.

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerAlias tech2
DocumentRoot /var/www/html/tech2/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Step #05: Enable tech1 site using a2ensite command

root@Virtual-Machine:/etc/apache2/sites-available# a2ensite tech1.conf
Enabling site tech1.
To activate the new configuration, you need to run:
 service apache2 reload

Reload apache server

root@Virtual-Machine:/etc/apache2/sites-available# service apache2 reload

Enable tech2 site using a2ensite command

root@Virtual-Machine:/etc/apache2/sites-available# a2ensite tech2.conf
Enabling site tech2.
To activate the new configuration, you need to run:
 service apache2 reload

Now reload apache server

root@Virtual-Machine:/etc/apache2/sites-available# service apache2 reload

Step #06: Now goto created web directory /var/www/html/tech1 and then create new index.html or index.php file.

# touch index.html

# touch index.php

root@Virtual-Machine:/var/www/html/tech1# vi index.php

Insert below all lines into index.php file

<!DOCTYPE html>
<html>
<body>

<h1>This is Tech1 site</h1>
<p>This is Tech1 site.</p>

</body>
</html>

Step #07: Now goto created web directory /var/www/html/tech2 and then create new index.html or index.php file.

# touch index.html

# touch index.php

Insert below all lines into index.php file

<!DOCTYPE html>
<html>
<body>

<h1>This is Tech2 site</h1>
<p>This is Tech2 site.</p>

</body>
</html>

Final Step : Now test your created two sites. Goto browser and type your ip address and directory name like as below

http://10.66.10.11/tech1/

See example like as:

This is Tech1 site

This is Tech1 site.

http://10.66.10.11/tech2/

See example like as:

This is Tech1 site

This is Tech1 site.

Thank You Very Much Reading My Post. If any query please send me comment.

0 0 votes
Article Rating
Admin: I am system administrator as Windows and Linux platform. I have 4 years skilled from the professional period. I have to configure Linux based system such as an Asterisk VOIP system, Network monitoring tools (ZABBIX), Virtualization (XEN Server), Cloud computing (Apache CloudStack) etc. Now share my professional skill each interested person. Thanks to all.
Leave a Comment