LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Help with apache with virtual hosts (https://www.linuxquestions.org/questions/slackware-14/help-with-apache-with-virtual-hosts-904408/)

qlands 09-22-2011 07:01 AM

Help with apache with virtual hosts
 
Hi,

What do I need to do to use virtual hosts in apache?

I have this configuration in httpd-vhosts.conf

Code:


#NameVirtualHost *:80

<VirtualHost *>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/srv/httpd/htdocs"
    ServerName rmg.ilri.cgiar.org
    ErrorLog "/var/log/httpd/error_log"
    CustomLog "/var/log/httpd/access_log" common
</VirtualHost>

<VirtualHost *>
    <Directory /var/www/git.darkstar.ilri.org/gitorious/public>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from All
    </Directory>

    DocumentRoot /var/www/git.darkstar.ilri.org/gitorious/public
    ServerName repository.rmg.ilri.cgiar.org

    ErrorLog /var/log/httpd/repository_log
    CustomLog /var/log/httpd/repository_log combined

    # Gzip/Deflate
    # http://fluxura.com/2006/5/19/apache-for-static-and-mongrel-for-rails-with-mod_deflate-and-capistrano-support
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Far future expires date
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
        ExpiresActive On
        ExpiresDefault "access plus 1 year"
    </FilesMatch>

    # No Etags
    FileETag None

    RewriteEngine On

    # Check for maintenance file and redirect all requests
    RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
    RewriteCond %{SCRIPT_FILENAME} !maintenance.html
    RewriteRule ^.*$ /system/maintenance.html [L]
</VirtualHost>

But when I type rmg.ilri.cgiar.org or repository.rmg.ilri.cgiar.org both go to the DocumentRoot of the first (/srv/httpd/htdocs)!

Do I need to remove some lines from httpd.conf if I use virtual hosts?

Both rmg.ilri.cgiar.org and repository.rmg.ilri.cgiar.org are declared elsewhere in a Windows Domain server.

Any help is much appreciated.
Carlos

qlands 09-22-2011 07:26 AM

I fixed!

Just un-commented NameVirtualHost *:80 and added *:80 to each virtual host and works perfectly!

ponce 09-22-2011 07:29 AM

you have to uncomment the NameVirtualHost directive to use name-based virtual hosting.

oops, too late :D


All times are GMT -5. The time now is 11:50 PM.