Kovaz
Kovaz

Reputation: 127

Host multiple domains with apache

I'm trying to set up an ubuntu server to act as a dns server and host a simple webpage, some git repos, and some software for issue tracking, code review, and the like. I settled on Phabricator as the issue tracking/ code review software of choice, since it seemed to be a good all-in-one solution. I've got my server hosting my webpage and git repos, so that part seems to be working ok. Now here's the issue I've run into (from Phabricator configuration instructions):

If you haven't already, set up a domain name to point to the host you're installing on. You can either install Phabricator on a subdomain (like phabricator.example.com) or an entire domain, but you can not install it in some subdirectory of an existing website

I have no idea where to even begin setting up another domain name on my server. How do I set up a second domain name for Phabricator to use?

I see a lot of guides online that say to modify resolv.conf to add a dns entry, however mine looks like this:

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.1.1

and I'm not sure what I should change to get dns entries to show up here.

Upvotes: 1

Views: 510

Answers (1)

Michael McAuliffe
Michael McAuliffe

Reputation: 21

I'm assuming you have only one IP address, which means you should be using virtual name-based hosting. There are a number of tutorials for doing this, but in short:

Create a virtual host configuration file in:

/etc/apache2/sites-available

For example:

nano /etc/apache2/sites-available/phabricator

Run:

a2ensite phabricator (in this example, but use the configuration file name you used above)
apache2ctl restart

The configuration file (which can be named whatever you'd like) needs to contain a number of items. A simple example would look like this:

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com
</VirtualHost>

DocumentRoot is the full path to the root of your site, usually where index.html, index.php, or the like is located. The default is /var/www. You could put somethig like /home/phabricator or /var/www/phabricator, but make sure you install Phabricator in the directory you specify.

ServerName is the full FQDN of your site, such as "www.google.com" or "phabricator.yourdomain.com" or even "phabricator.local". Basically it's the same value as you have set in your DNS for your A record, or in your /etc/hosts file. If you don't know about /etc/hosts, then disregard that part.

You'll probably need a few more directives in your configuration file, but you can find what's available on Google. I would suggest following some tutorials to get your configuraiton right.

But overall, you just need to create a virtual host config file, enable it, then restart the server, which is what the above instructions do. Apache will respond to the web request based on the site you put into your address bar.

P.S. Just noticed your DNS part of the question. Do you have DNS set up publicly to point a domain (example.com) or subdomain (something.example.com) to your server's IP address?

Upvotes: 2

Related Questions