How can I point multiple domains to one server? - dns

I have a VPS that's barely being used. I would love to point several domains I have (through a registrar somewhere else) to different folders of this VPS. Is there any way to do this?
For example:
helloomgwtf.com -> 111.111.111.111/hello
hitherehowareyou.com -> 111.111.111.111/hithere
thirdrandomdomain.com -> 111.111.111.111/random
I'm entirely new to setting stuff up, so detailed explanations would really be appreciated.
Thanks!

You are looking for Virtual Hosts.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName helloomgwtf.com
DocumentRoot /var/www/vhosts/hello
</VirtualHost>
<VirtualHost *:80>
ServerName hitherehowareyou.com
DocumentRoot /var/www/vhosts/hithere
</VirtualHost>
<VirtualHost *:80>
ServerName thirdrandomdomain.com
DocumentRoot /var/www/vhosts/random
</VirtualHost>
Rackspace has pretty good info on this here.

Related

Hosting multiple websites on AWS - Amazon Linux EC2

I'm trying to host multiple website on Amazon Ec2 linux, but it is only show the first website. I try as following virtual host configuration in httpd.conf.
<VirtualHost *:80>
ServerAdmin ec2-user#ec2-54-169-185-24.ap-southeast-1.compute.amazonaws.com
DocumentRoot "/var/www/html/chitthu.co"
ServerName www.chitthu.co
ErrorLog "logs/chitthu.co-error_log"
CustomLog "logs/yourdomain.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin ec2-user#ec2-54-169-185-24.ap-southeast-1.compute.amazonaws.com
DocumentRoot "/var/www/html/burmanews.co"
ServerName www.burmanews.co
ErrorLog "logs/burmanews.co-error_log"
CustomLog "logs/burmanews.co-access_log" common
</VirtualHost>
And Point both of domain name to same public ip address of EC2 instance. And that is still not working for me.
Problem Solved, I allocate new Elastic ip and associate with my EC2 instance, point all domain with that ip is working perfectly.

Apache httpd.conf settings for virtual hosting from different directories

I have 3 websites running on a cloud server, with the default Apache httpd.conf setting . I have uncommented the NameVirtualHost and configured the 3 websites from VirtualHost, after set up the DocumentRoot and ServerName for each, all worked perfectly but only the site within the default Directory is working for mod-rewrite, which I used for SEO URLs. The other 2 sites are located just one level above the /var/www/html, and are in the subfolder of /var/www/websites/site1, site2. I've tried to use RewriteBase in the .htaccess file to make this work but no success, and I have no idea where in the httpd.conf file I can make any changes to get things right. Please help, thanks.
If I understand you correctly you wish to have 3 separate websites running on 1 Apache server and then be able to have rewrites working on all of them.
You are on the right track using VirtualHosts. You need to stick to using a separate VirtualHost for each website you intend to host.
Given a folder structure as follows
/var/www/
- /websites
-- /site1
-- /site2
-- /site3
You can then setup 3 VirtualHosts for each of your 3 sites:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain1.tld
DocumentRoot /var/www/websites/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.tld
DocumentRoot /var/www/websites/site2
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.tld
DocumentRoot /var/www/websites/site3
</VirtualHost>
Hope this helps.

Forward two different websites to the same server

I'm pretty new in webserver management. So I rented this server, and setup a LAMP server with MySql and everything is alright in that sense.
The problem is now that I have two different domains (say www.domain1.com, www.domain2.org), and I want each of them to load the website content from a different folder on my server.
How can I do that?
I tried to google some relevant terms, but I couldn't find what that's called.
Thank you for any efforts.
If you use Apache2, you can use the ServerName directive in the VirtualHost configuration:
<VirtualHost *:80>
ServerName www.domain1.com
DocumentRoot /folder1
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.com
DocumentRoot /folder2
</VirtualHost>

virtual hosts are linked to internal address

I am trying to transfere my website in my new server.
I have an internal adresse.ex: xxx-wwwyyy.net
www.site1.com : production web site
www.site2.com : preproduction web site
In my site-available folder I created some vhost files:www.site1.com and www.site2.com
The problem is that both of them are linked to xxx-wwwyyy.net:
If I create a vhost for xxx-wwwyyy.net and i give it my site folder adress:
/var/www/site/prod ,
then my **www.site1.com** and **www.site2.com** go to the same adresse.
If I delete xxx-wwwyyy.net , all of them go to /var/www/
I am just confuised. has anyone any idea?
hello you are trying to create name-based virtual hosts.. make sure NameVirtualHOst *:80 is uncommented in your httpd.conf ... have a look in here:
http://httpd.apache.org/docs/2.2/vhosts/name-based.html
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

Apache Virtual Host - xxx.241.214.xxx:80 has no VirtualHosts

I'm trying to set up a virtual host on a new VPS using apache 2.x on a Ubuntu server.
When starting apache I get the error " xxx.241.214.xxx:80 has no VirtualHosts", and the url for the site still points to the default location which means my virtual host file isn't taking effect:
<VirtualHost xxx.241.214.xxx:80>
ServerName xxx.co.uk
ServerAlias www.xxx.co.uk
DocumentRoot /var/www/vhosts/xxx.co.uk/httpdocs/xxx.co.uk
</VirtualHost>
Please help, I'm no good at all this server config stuff.
I know its been a while since you posted your question but I thought id throw in my thoughts
We currently run a few internal sites here for different purposes, all of them listen of standard port 80 and apache is set up simply as follows
Listen 80
NameVirtualHost *:80
# Site 1 Comment
<VirtualHost *:80>
ServerName site1.intranet
ServerAdmin administrator#whatever.com
DocumentRoot /var/www/html/site1
</VirtualHost>
# Site 2 Comment
<VirtualHost *:80>
ServerName site2.intranet
ServerAdmin administrator#whatever.com
DocumentRoot /var/www/html/site2
</VirtualHost>
Our DNS is set up to route http://site1.intranet etc to the IP of the apache server and the apache config does the rest.
I always use
<VirtualHost *>
(and ISTR always having problems specifying the IP and port number, which I think is why I do it that way now).

Resources