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.
Related
I have two local web site project, localgoogle.com and localapple.com.
localgoogle.com files are in /home/vahid/dev/localgoogle
localapple.com files are in /home/vahid/dev/localapple
My OS is debian 8.5, I have apache2 installed.
I made /etc/apache2/sites-available/localgoogle.com.conf
and /etc/apache2/sites-available/localapple.com.conf
both linked to /etc/apache2/sites-enabled and enabled by a2ensite command.
This is localgoole.com.conf:
<VirtualHost *:80>
ServerName localgoogle.com
ServerAdmin webmaster#localgoogle.com
DocumentRoot /home/vahid/dev/localgoogle
ServerAlias www.localgoogle.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
localapple conf file follow above configuration rule.
I restarted apache2 service, but I don't know why and how to access this virtualhosts from browser!
I tried localhost/localgoogle.com in browser but It's return Not Found
You access the site directly as localgoogle.com from your browser. Make sure that the name resolves to your local ip address using hosts file or dns.
An Apache web server for the domain “www.abc.lk” is configured and hosted in a hosting server with the IP address 192.168.2.105. Another domain called “www.def.lk” should also be configured with the same content without any duplication. Explain the configuration of the Apache server with name-based virtual hosting for the above requirement?
You have to configure two virtual host with same DocumentRoot but different ServerNames
http://httpd.apache.org/docs/2.2/vhosts/examples.html
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.abc.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.123.com
# Other directives here
</VirtualHost>
Why don't you just use www.abc.lk as ServerName and www.def.lk as ServerAlias in your vhost configuration ?
And of course be sure that both DNS point to the server.
Here is what I use (I think this link lays out all of the solutions or possibilities):
https://realtechtalk.com/Apache_Vhost_HowTo_Serve_Same_Content_using_a_different_domain_and_IP-1730-articles
Here is another way of doing it that is more simple than symlinking or duplicating content between vhosts:
This would be in your vhost.conf
ServerName differentdomain.com
ServerAlias www.differentdomain.com
ProxyPass / http://yourmainsite.com/
ProxyPassReverse / http://yourmainsite.com/
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.
Working on CentOS (specifically the Amazon EC2 Linux AMI). I have 2 virtual host on my apache, and I would like them to log on different rsyslog facilities, so I configured my hosts like this:
<VirtualHost *:80>
DocumentRoot /var/www/site1
ServerName www.site1.com
ServerAlias alias1
ErrorLog syslog:local1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/site3
ServerName www.site3.com
ServerAlias alias3
ErrorLog syslog:local3
</VirtualHost>
and in my rsyslog conf I set up 2 forwarding rules:
local1.* /logFile1
local3.* /logFile3
But everything goes into logFile1, as if the 2 virtualhost were sharing the syslog facilities. I can't understand what's happening.
Found by my self, there a note on apache docs (http://httpd.apache.org/docs/current/mod/core.html#errorlog) saying:
The facility is effectively global, and if it is changed in individual virtual hosts, the final facility specified affects the entire server.
sadly.
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).