subdomain question
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
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?
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.
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
Then, make sure to enable both sites with a2ensite NAME.
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>
Delete the "Listen 173.x.x.x:80" line, and change the "Listen 174.x.x.x:80" to "Listen *:80"
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>
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
ServerName files.example.com
DocumentRoot /home/site1/public_html/files
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined
ServerName example.com
DocumentRoot /home/site1/public_html/
ErrorLog /home/site1/logs/error.log
CustomLog /home/site1/log/access.log combined
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.
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.
1) You've not set up static networking according to this guide
or 2) You've not rebooted after setting up the 2nd ip.
Now It works.
Thanks again.