Solved

vhost alias issues

Posted on 2011-02-18
15
691 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

717 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