Setting Up Subdomain In Ubuntu 10.04 server - subdomain

I am not able to setup subdomain through virtual host in my ubuntu server. Followed following steps
in /etc/hosts
127.0.0.1 localhost
10.0.0.1 domain.com
10.0.0.1 sub.domain.com
in /etc/apache2/sites-available/ i created two files domain.com and sub.domain.com
in domain.com file,
<VirtualHost *:80>
ServerAdmin webmaster#domain.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/
ErrorLog /var/www/domain.com/logs/error.log
CustomLog /var/www/domain.com/logs/access.log combined (all these folders exists)
</VirtualHost>
in sub.domain.com file,
<VirtualHost *:80>
ServerAdmin webmaster#sub.domain.com
ServerName sub.domain.com
ServerAlias www.sub.domain.com
DocumentRoot /var/www/sub.domain.com/
ErrorLog /var/www/sub.domain.com/logs/error.log
CustomLog /var/www/sub.domain.com/logs/access.log combined (all these folders exists)
</VirtualHost>
After this is i enabled the site by a2ensite domain.com, a2ensite sub.domain.com and then restarted apache server.
Domain.com works fine. But sub.domain.com is not working. I am getting error "Webpage not available".
Can anyone tell me what is the mistake i am doing??

Related

Server without www returns 404

I'm running Apache2 on Debian Jessie, when i try to enter my site without www. it returns a 404 page.
What i have in apache config:
<VirtualHost *:80>
DocumentRoot "/var/www/sites/example.com"
ServerName www.example.com
ServerAlias example.com
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
DocumentRoot "/var/www/sites/example.com"
ServerName www.example.com
ServerAlias example.com
SSLCertificateFile /etc/chain.pem
SSLCertificateKeyFile /etc/key.pem
</VirtualHost>`
Now , there are no other definitions in "sites-enabled" that mentions the site
1- Both example.com and www.example.com have the same ip ( Not a DNS problem )
2- There are no extra configurations in "sites-available"
3- https://example.com works fine but http://example.com returns a 404
There was a <VirtualHost *:80> that has no ServerName , and apache used default server hostname which was example.com

2 Virtual Hosts on Mac

Hi to everyone I have two different sites and I want to two different host:
movie.local
music.local
These are my files:
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 movie.local
127.0.0.1 music.local
And
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName movie.local
ServerAlias www.movie.local
DocumentRoot "/Users/Me/Sites/movie"
ErrorLog "/private/var/log/apache2/site-error_log"
CustomLog "/private/var/log/apache2/site-access_log" common
ServerAdmin neilgee#coolestguidesontheplanet.com
<Directory "/Users/Me/Sites/movie">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName music.local
ServerAlias www.music.local
DocumentRoot "/Users/Me/Sites/music"
ErrorLog "/private/var/log/apache2/site-error_log"
CustomLog "/private/var/log/apache2/site-access_log" common
ServerAdmin neilgee#coolestguidesontheplanet.com
<Directory "/Users/Me/Sites/music">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But now if I go to movie.local that's ok, but if i go to music.local my browser will load the content of movie.local, why?
if i go to music.local my browser will load the content of movie.local, why?
You can create a subdomain on your localhost like this.
First create a virtual host:
<VirtualHost *:80>
ServerName music.localhost
DocumentRoot "C:/Users/Me/Sites/music"
<Directory "C:/Users/Me/Sites/music">
/....../
/....../
</Directory>
</VirtualHost>
And in your hosts file add this line:
127.0.0.1 music.localhost

Trouble configuring virtual hosts on apache2

I'm trying to configure two sites running on the same apache server with virtualhosts. Somehow whatever i try to configure apache has always problems with my config. Here is the configuration file
Listen 80
Listen 8080
NameVirtualHost 172.16.10.2:80
NameVirtualHost 172.16.10.2:8080
<VirtualHost 172.16.10.2:80>
ServerName be.wincars.local
DocumentRoot /var/www/wincarsbe
CustomLog /var/www/logs/wincarsbe.log combined
ErrorLog /var/www/logs/wincarsbe.log
</VirtualHost>
<VirtualHost 172.16.10.2:8080>
ServerName com.wincars.local
DocumentRoot /var/www/wincarscom
CustomLog/var/www/logs/wincarscom.log combined
ErrorLog /var/www/logs/wincarscom.log
</VirtualHost>
When i try to restart apache, here is what I get:
Try something like
Listen 80
....
NameVirtualHost *:80
<VirtualHost *:80>
ServerName be.wincars.local
...
</VirtualHost>
<VirtualHost *:80>
ServerName com.wincars.local
...
</VirtualHost>
You can also try make Apache dump out information about configured VirtualHosts:
httpd -t -D DUMP_VHOSTS

Access Local sub domain with IP in wamp

What I need is as follows
I am able to access the sub domain in my local machine as follows test.localhost but I need test.myMachineName or test.myMachineIp to access from another computer in my own network
I have setup the sub domain in my local wamp server as follows:
IN https-vhost.conf:
<VirtualHost *:80>
#ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
#ErrorLog "logs/dummy-host.example.com-error.log"
#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
#ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/wamp/www/test"
ServerName localhost
ServerAlias test.localhost
#ErrorLog "logs/dummy-host.example.com-error.log"
#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
And then enabled vhost in httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then added in windows host as follows
127.0.0.1 test.localhost
I don't understand your configuration. First, if you access test.localhost from another computer will not work because your website does not exist on that computer. You have to use the IP address and port forwarding in your router settings (Private IP: Computer local IP, Type: TCP, Range: 80 - 80).
In https-vhost.conf:
<VirtualHost *:80>
#ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
#ErrorLog "logs/dummy-host.example.com-error.log"
#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
#ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/wamp/www/test"
ServerName test.youripaddress
ServerAlias test.youripaddress
#ErrorLog "logs/dummy-host.example.com-error.log"
#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
In HOST file:
127.0.0.1 localhost
youripaddress test.youripaddress
Ask me any questions.

Problem with configuring virtual hosts

Some details
XAMPP 1.7.1
OS tested on vista and xp
Hello everyone. I have some problems with configuring my virtual hosts.
Currently I have two sites.
Here is my vhost.conf file:
<VirtualHost *:80>
ServerAdmin me#site.nl
DocumentRoot c:/xampp/htdocs/site1/trunk/
ServerName site1.local
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me#site.nl
DocumentRoot c:/xampp/htdocs/site2/trunk/
ServerName site2.local
</VirtualHost>
And of course in my host file I have
127.0.0.1 site1.local
127.0.0.1 site2.local
I have restarted apache as well as my browser various times.
Here is my problem:
http://site1.local works. But when i go to http://site2.local, I land at site1.local.
any idea's?
Try
<VirtualHost "site1.local">
ServerAdmin spam#a1230912##ad#.nl
DocumentRoot c:/xampp/htdocs/site1/trunk/
ServerName site1.local
</VirtualHost>
<VirtualHost "site2.local">
ServerAdmin spam#a1230912##ad#.nl
DocumentRoot c:/xampp/htdocs/site2/trunk/
ServerName site2.local
</VirtualHost>
You always get site1 because Apache default to the first.
edit
Uncomment
#NameVirtualHost *
to
NameVirtualHost *
In your httpd.conf
Mine says (/etc/httpd/conf/httpd.conf)
126 # Listen: Allows you to bind Apache to specific IP addresses and/or
127 # ports, in addition to the default. See also the <VirtualHost>
128 # directive.
129 #
130 # Change this to Listen on specific IP addresses as shown below to
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
132 #
133 Listen 127.0.0.1:80
134 NameVirtualHost 127.0.0.1
And my vhost file has
<VirtualHost "www.whatever.com">
DocumentRoot /var/www/html/whatever/pub
ErrorLog logs/error_log
ServerName www.whatever.com
...