0

I have Ubuntu 14.04 Server with Apache.

All I want if people enter to server IP like x.x.x.x forward to DocumentRoot /var/www/site1/html

And if enter to my domain address like site.com forward to DocumentRoot /var/www/site2/html

How could it possible?

mahdi
  • 3

1 Answers1

1

You need to configure your virtual hosts. In directory /etc/apache2/sites-available/ you may find example of virtual host files. So the steps are:

1. Create a virtual host file

sudo nano /etc/apache2/sites-available/site.com.conf

and set a content

<VirtualHost *:80>
    ServerAdmin admin@site.com
    ServerName site.com
    ServerAlias www.site.com
    DocumentRoot /var/www/site1/html
</VirtualHost>

It is a simple example. You can read manuals, to get more. Now just take in account, that you need to configure separate file for each site you want to run.

2. Enable your VH

When you finished your VH config, you need to enable your host by command:

sudo a2ensite site.com.conf

3. Reload Apache

To apply new host, you need to reload Apache

sudo service apache2 reload

Now it should work.

lucius
  • 147