Solved

vhost alias issues

Posted on 2011-02-18
15
681 Views
Last Modified: 2012-08-14
hiya all

I have a stand alone linux box that i am running apache on.

I have 2 site configured in the vhost file and both site work fine but when i add in a ServerAlias but these are not working :(

Also the serve runs on a single ip address

here are my vhost directives

##################################
# SiteName
##################################


<VirtualHost       *:80>

    ServerAdmin webmaster@dummy-host.example.com
   
    DocumentRoot "/opt/bitnami/apps/SiteName"
   
    ServerName *.SiteName
    ServerAlias www.SiteName
   
    ErrorLog "logs/SiteName-error_log"
    CustomLog "logs/SiteName-access_log" common
   
    <Directory "/opt/bitnami/apps/SiteName">
    Order allow,deny
    Allow from all
    </Directory>
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
</VirtualHost>
0
Comment
Question by:willa666
  • 7
  • 6
  • 2
15 Comments
 
LVL 2

Expert Comment

by:TimBare
ID: 34930210
change
  ServerName *.SiteName
  ServerAlias www.SiteName

Open in new window

to
  ServerName SiteName
  ServerAlias www.SiteName

Open in new window

0
 
LVL 1

Author Comment

by:willa666
ID: 34930240
hi TimBare

i just changed this and still only get to the via via the Servername.

forgot to mention i have 2 vhost directives and the server name sites work fine but the server alisa on the second directive displayes the site in teh first directive. i m wondering if the first site is somehow the defualt site when you hit teh ip address.

0
 
LVL 1

Author Comment

by:willa666
ID: 34930247
in fact if i hitthe IP address directily i get the site in the first directive :)
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 2

Expert Comment

by:TimBare
ID: 34930248
did you restart apache after adding the alias?
0
 
LVL 2

Expert Comment

by:TimBare
ID: 34930271
assuming you're running ubuntu and apache2, here's the syntax if you need it:

sudo /etc/init.d/apache2 restart

Open in new window

0
 
LVL 1

Author Comment

by:willa666
ID: 34930276
:) yeap i restarted apache after the conf change :)
0
 
LVL 2

Expert Comment

by:TimBare
ID: 34930277
as far as hitting the site in the first directive at the IP, this is proper behavior. that is your "default site." If you have a DNS name pointing to the server IP, it will look for a virtualhost w/ the name that it's got. If it finds it, it opens up that site. If it doesn't, it returns a 404.
0
 
LVL 2

Expert Comment

by:TimBare
ID: 34930284
here's a second site in my sites-available/default file
<VirtualHost *:80>
        ServerAdmin webmaster@tbare.com
        ServerName test.dom
        ServerAlias www.test.dom
        ServerAlias dev.test.dom
        DocumentRoot /var/www/test.dom/site/
</VirtualHost>

Open in new window


Pointing all 3 DNS names to the IP of my server, i get to the site in my /var/www/testl.dom/site/ directory...

Try simplifying yours to the above, and see if you have better luck... then add the other stuff one section at a time and see where it breaks. Be sure to restart apache after each edit (which you said you did, so kudos... that was my biggest mistake when i was setting mine up the first time...)
0
 
LVL 1

Author Comment

by:willa666
ID: 34930292
sounds like a plan! lets see how we go :)
0
 
LVL 1

Author Comment

by:willa666
ID: 34930402
hmm i have set the first and second directives to these minual directives but i am unable to access them from teh frontend. i get a "403 Forbidden- You don't have permission to access / on this server." message from both sites


<VirtualHost *:80>
        ServerAdmin email@address.com
        ServerName SiteName.com
        ServerAlias www. SiteName.com
        DocumentRoot /opt/bitnami/apps/SiteName/htdocs
</VirtualHost>

Open in new window

0
 
LVL 2

Expert Comment

by:TimBare
ID: 34930457
what permissions do you have set on the folder? use

sudo chmod 0755 -R /opt/bitnami/apps/SiteName/htdocs

Open in new window


0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34932581
Have you set up a DNS entry at the nameserver for www?
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 34932660
I have just noticed you have a space in your serverAlias

ServerAlias www. SiteName.com

should be

ServerAlias www.SiteName.com
0
 
LVL 2

Accepted Solution

by:
TimBare earned 500 total points
ID: 34933225
good catch, bportlock... w/ the 403, i still think it's permissions, though.

Did you change the permissions to the folder to make it world readable?
0
 
LVL 1

Author Comment

by:willa666
ID: 34933646
hiya all

So i managed to get it sorted, below is teh final config that worked for me. but now i have found that mod rewrite does not seem to be working, but i have never seen it working on this server so i will open up anotehr question for that one :)


<VirtualHost       *:80>

      ServerAdmin SiteName@SiteName.com
      DocumentRoot "/opt/bitnami/apps/SiteName/htdocs"
      ServerName SiteName.com:80
      ServerAlias www.SiteName.com
      ServerAlias SiteName.co.uk
      ServerAlias www.SiteName.co.uk
      
      ErrorLog "logs/SiteName.com-error_log"
      CustomLog "logs/SiteName.com-access_log" common
      <Directory "/opt/bitnami/apps/SiteName/htdocs">
            Order allow,deny
            Allow from all
            #Allow from 127.0.0.1
      </Directory>
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]
</VirtualHost>
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question