subdomain question

I have 2 ip address.

I want example.com use 173.x.x.x and files.example.com use 174.x.x.x.

Now example.com works well but files.example.com can't work.

Anyone help me? Thank you.

DNS Record(use Linode DNS):

A/AAAA Records
Hostname     IP Address  TTL               
                 173.x.x.x      Default     
files                  174.x.x.x      Default     

I use debian5.0 32bit system。

ports.onf:

NameVirtualHost 173.x.x.x:80
NameVirtualHost 174.x.x.x:80
Listen 80
 <ifmodule mod_ssl.c="">Listen 443</ifmodule> 

sites-available/example.com:(This works fine)

 <virtualhost 173.x.x.x:80="">ServerAdmin admin@example.com
ServerName example.com
DocumentRoot /home/site1/public_html/
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined
 <directory home="" site1="" public_html="">Options FollowSymLinks
AllowOverride All</directory></virtualhost> 

sites-available/files.example.com:(This can't work)

 <virtualhost 174.x.x.x:80="">ServerAdmin admin@example.com
ServerName files.example.com
DocumentRoot /home/site1/public_html/files
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined</virtualhost> 

13 Replies

You can only have one NameVirtualHost declaration. Use *:80

http://wiki.apache.org/httpd/CommonMisc … iple_times">http://wiki.apache.org/httpd/CommonMisconfigurations#UsingthesameListenand.2BAC8-orNameVirtualHostmultiple_times.

An error occurred :

Reloading web server config:apache2[Mon Jan 03 07:22:35 2011] [warm] NameVirtualHost *:80 has no VirtualHosts.

Now I change example.com & files.example.com to:

 <virtualhost *:80="">ServerAdmin admin@example.com 
..........
..........</virtualhost> 

Is this right?

I have changed in my server.No error but files.example.com still not work

After this,I try to change ports.conf to

 <ifmodule mod_ssl.c="">Listen 443</ifmodule> 

example.com to

NameVirtualHost 173.x.x.x:80
Listen 80
 <virtualhost 173.x.x.x:80="">ServerAdmin admin@example.com
ServerName example.com
DocumentRoot /home/site1/public_html/
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined
 <directory home="" site1="" public_html="">Options FollowSymLinks
AllowOverride All</directory></virtualhost> 

files.example.com to

NameVirtualHost 174.x.x.x:8080
Listen 8080
 <virtualhost 174.x.x.x:8080="">ServerAdmin admin@example.com
ServerName files.example.com
DocumentRoot /home/site1/public_html/files
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined</virtualhost> 

but it's also not work…….

@BarkerJr:

You can only have one NameVirtualHost declaration. Use *:80

http://wiki.apache.org/httpd/CommonMisc … iple_times">http://wiki.apache.org/httpd/CommonMisconfigurations#UsingthesameListenand.2BAC8-orNameVirtualHostmultiple_times.

That's a false statement. The problem is having identical NameVirtualHost statements, not multiple different ones.

What you want is this:

ports.conf:

NameVirtualHost 173.x.x.x:80
Listen 173.x.x.x:80

NameVirtualHost 174.x.x.x:80
Listen 174.x.x.x:80

And then both your sites-available as they were before. (Both should have a line where IP_ADDRESS:PORT matches exactly to the NameVirtualHost line)

Then, make sure to enable both sites with a2ensite NAME.

thanks for your reply but it also has error meeage….

Starting web server:apache2(99)Cannot assign requested address:make_sock:could not bind to address 174.x.x.x:80
no listening sockets available,shutting down
Uable to open logs

ports.conf:

NameVirtualHost 173.x.x.x:80
Listen 173.x.x.x:80
NameVirtualHost 174.x.x.x:80
Listen 174.x.x.x:80
 <ifmodule mod_ssl.c="">Listen 443</ifmodule> 

example.com:

 <virtualhost 173.x.x.x:80="">ServerAdmin admin@example.com
ServerName example.com
DocumentRoot /home/site1/public_html/
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined
 <directory home="" site1="" public_html="">Options FollowSymLinks
AllowOverride All</directory></virtualhost> 

files.example.com:

 <virtualhost 174.x.x.x:80="">ServerAdmin admin@example.com
ServerName files.example.com
DocumentRoot /home/site1/public_html/files
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined</virtualhost> 

Ok, so I apparently fail at thinking early in the morning.

Delete the "Listen 173.x.x.x:80" line, and change the "Listen 174.x.x.x:80" to "Listen *:80"

also error。。。。

Retarting web server:apache2[Mon Jan 03 09:42:15 2011] [warn]NameVirtualHost *:80 has no VirtualHosts

ports.conf:

NameVirtualHost *:80
Listen 80
 <ifmodule mod_ssl.c="">Listen 443</ifmodule> 

You are having problems.

Ok here's what you need

Listen *:80

NameVirtualHost *:80

Make sure you have no other Listen/NameVirtualHost directives anywhere else.

Then you need two virtual host configurations for

ServerAdmin admin@example.com

ServerName files.example.com

DocumentRoot /home/site1/public_html/files

ErrorLog /home/site1/logs/error.log

CustomLog /home/site1/log/access.log combined

ServerAdmin admin@example.com

ServerName example.com

DocumentRoot /home/site1/public_html/

ErrorLog /home/site1/logs/error.log

CustomLog /home/site1/log/access.log combined

Options FollowSymLinks

AllowOverride All

You should also ensure you can ping both example.com and files.example.com

Lastly as hoopycat likes to say, "Please consider not redacting your host or domain name when asking questions." It would make things easier.

According to your method,"files.wrust.me"still not work.But I find a question files.wrust.me can't pass ping.

Pinging wrust.me [173.230.152.x] with 32 bytes of data
Reply from 173.230.152.x: bytes=32 time=176ms TTL=52
Reply from 173.230.152.x: bytes=32 time=178ms TTL=52
Reply from 173.230.152.x: bytes=32 time=177ms TTL=52
Reply from 173.230.152.x: bytes=32 time=176ms TTL=52

Pinging files.wrust.me [173.230.156.xx] with 32 bytes of data:(This is the 174.x.x.x of the previous)
Request timed out.
Request timed out.
Request timed out.
Request timed out.

I bet either

1) You've not set up static networking according to this guide http://library.linode.com/networking/co … nterfaces/">http://library.linode.com/networking/configuring-static-ip-interfaces/

or 2) You've not rebooted after setting up the 2nd ip.

Thank you.I forget to add "auto eth0 eth0:0 eth0:1" in /etc/network/interfaces.

Now It works.

Thanks again.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct