Solved

vhost alias issues

Posted on 2011-02-18
15
685 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

732 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