VIRTUAL HOST FOR APACHE HTTP SERVER

Hi all, from this post I’m going to show you how to configure the virtual host in Apache HTTP server. When we have created a virtual host in our Apache server, then we can access different projects as the server. Normally we are accessing the apache server hosts using the ‘localhost‘ or by using the IP address, ‘127.0.0.1‘. But when we have configured virtual hosts, then we can access by giving a url as well. Let’s see how to do the configuration step by step.

  • First of all you have to open the ‘httpd.conf‘ file from your apache server installation location. The default path is ‘/usr/local/apache2/conf/httpd.conf‘.

1.png

2.png

  • At the end of the file, there is a line like below which has been commented. We should to remove the comment.

3

4

  • Then save and exit the file.
  • Next you can create a folder and your web page at desired location.

10

11

  • Should change the directory and file permissions to be executed as well.

chmod a+x firstVirtualHost

chmod a+x index.html

  • Next we need open the ‘httpd-vhosts.conf‘ file which is located at ‘/usr/local/apache2/conf/extra/‘ by default.

6

7

  • Then you should edit the document like below.

8.png

Document root = Where the virtual host file is located. The directory you created.

Server name = anything you like

Server alias = anything you like. This is the domain what we are going to use to access the virtual host.

<Directory></Directory> : Same as the document root, but this is very important.

  • Just one more thing to do. Access the ‘users‘ file which is located at ‘/etc/‘ and change like below with your Server alias and IP address.

13

14

15

  • Now you are ready to go. Open your browser and type the ‘localhost‘, this will show your normal index file. Then type your server alias which you ave earlier. It’s working too.

 18

19

Hope now you have a clear idea about what the virtual host means and how to configure virtual host in Apache HTTP server. Thank You!

Advertisements

One thought on “VIRTUAL HOST FOR APACHE HTTP SERVER

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s