Solved

vhost alias issues

Posted on 2011-02-18
15
647 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
Comment Utility
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
Comment Utility
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
Comment Utility
in fact if i hitthe IP address directily i get the site in the first directive :)
0
 
LVL 2

Expert Comment

by:TimBare
Comment Utility
did you restart apache after adding the alias?
0
 
LVL 2

Expert Comment

by:TimBare
Comment Utility
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
Comment Utility
:) yeap i restarted apache after the conf change :)
0
 
LVL 2

Expert Comment

by:TimBare
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:TimBare
Comment Utility
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
Comment Utility
sounds like a plan! lets see how we go :)
0
 
LVL 1

Author Comment

by:willa666
Comment Utility
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
Comment Utility
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
Comment Utility
Have you set up a DNS entry at the nameserver for www?
0
 
LVL 34

Expert Comment

by:Beverley Portlock
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
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…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now