Hello Guys,
I'm having centos server in amazon ec2 with one public ip,
I need to host multiple domain on that server, First of all I created two user 1st is example1 and 2nd example2 for example1.com & example2.com.
created directory under /var/www/example.com/public_html for example1.com & /var/www/example2.com/public_html
and /var/www/html/index.html holding php.info file for if user type only ip in browser php details should be accessible..
now httpd.conf configuration
domain is listening on Listen 80 & NameVirtualHost *.80
<VirtualHost *:80>
ServerAdmin webmaster@example1.com
ServerName www.example1.com
ServerAlias example1.com
DocumentRoot /var/www/example1.com/public_html
ErrorLog /var/www/example1.com/error.log
CustomLog /var/www/example1.com/access.log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@example2.com
ServerName www.example2.com
ServerAlias example2.com
DocumentRoot /var/www/example2.com/public_html
ErrorLog /var/www/example2.com/error.log
CustomLog /var/www/example2.com/access.log common
</VirtualHost>
Main problem arises from here..
When I type example2.com in browser it works fine
but issue is when I type example1.com in browser it's work fine and displaying site also, but if I type public IP of server it displays example1.com site instead of phpinfo file..
httpd -S result
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 ip-X-X-X-X.eu-west-1.compute.internal (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server www.example1.com (/etc/httpd/conf/httpd.conf:1013)
port 80 namevhost www.example1.com (/etc/httpd/conf/httpd.conf:1013)
alias example1.com
port 80 namevhost www.example2.com (/etc/httpd/conf/httpd.conf:1022)
alias example1.com
Syntax OK
web server issue urgent help
Re: web server issue urgent help
According to the comments in an unmodified httpd.conf file:
With that in mind, why can't you just insert a 3rd virtual host before your 2 existing virtual hosts?
Where W.X.Y.Z is your IP address? (Or even a dummy name like http://www.example.com, but I think the IP address would be best if it works.)
--Don
Code: Select all
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
Code: Select all
<VirtualHost *:80>
ServerAdmin webmaster@whatever.com
ServerName W.X.Y.Z
DocumentRoot /var/www/html
ErrorLog /var/www/whatever/error.log
CustomLog /var/www/whatever/access.log common
</VirtualHost>
--Don
Re: web server issue urgent help
You're hosting on a PUBLIC cloud service with PUBLIC IP with PUBLIC domain names, yet you've obfuscated your "example" on a forum you've come to for help so much who can tell what.
Security thru Obscurity is a myth.
If you want help, post enough REAL INFO so that others can test and see what's wrong.
Security thru Obscurity is a myth.
If you want help, post enough REAL INFO so that others can test and see what's wrong.
For the 2.5^15th time :: Better Details = Better Answers