Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query Regarding Apache Setup

Tags:

apache

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.

like image 774
Hello Man Avatar asked Oct 30 '22 12:10

Hello Man


1 Answers

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.

like image 156
Hello Man Avatar answered Nov 15 '22 08:11

Hello Man