5

I have 2 websites on a Ubuntu 14.04 Server with Apache. The websites lie in /var/www. I have bought a couple of domains from Godaddy. I have linked the domain and the machine's IP.

Lets say I have abc.com and xyz.com. When a user tries to access abc.com, I need to show him the website under /var/www/abc/index.html and similarly for xyz.com.

I researched and found that under /etc/apache2/ there is some settings file I need to change in order to do it but I am not sure what to do. Could anybody give me a hint on how I can achieve this?

A detailed answer can be lot helpful for understanding.

1

1 Answer 1

2

So after a lot of research, I have found the answer to my question. I will share the steps I did to solve it.

  1. cd /etc/apache2/sites-available
  2. sudo cp 0* abc.com.conf
  3. sudo nano abc.com.conf
  4. sudo a2ensite abc.com.conf
  5. sudo service apache2 restart

The contents of abc.com.conf should be something similar to below code and don't touch anything else.

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName abc.com
    ServerAlias www.abc.com
    DocumentRoot /var/www/abc/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Similarly do so for the next website also.

Sign up to request clarification or add additional context in comments.

2 Comments

This is all debian specific. It's basic virtual host configuration.
Yes true that. Just didn't know the way to do in Ubuntu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.