Solved

vhost alias issues

Posted on 2011-02-18
15
659 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
 
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The viewer will learn how to count occurrences of each item in an array.
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 …

910 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

21 Experts available now in Live!

Get 1:1 Help Now