virtual host problems

Discussion in 'Server Operation' started by rbradshaw, Sep 28, 2008.

  1. rbradshaw

    rbradshaw New Member

    i have installed ubuntu 8.04 server from the perfect server howto and ive added two virtual hosts to /etc/apache2/sites-available/default:

    <VirtualHost *>
    ServerAdmin [email protected]
    DocumentRoot /home/user/htdocs/public_html
    ServerAlias site1.com *.site1.com
    </VirtualHost>


    <VirtualHost *>
    ServerAdmin [email protected]
    DocumentRoot /home/user/htdocs/public_html
    ServerAlias site2s.co.uk *.site2.co.uk
    </VirtualHost>

    when i type my ip into a browser it comes up with the 'it works' page, when i type the site1 url it loads the index page in the document root folder but when i type the site2 url it come up with an internal server error.

    can anybody please help correct this?

    thanks.
     
  2. rayit

    rayit Member

    try this?

    maybe you could try adding *:80

    ???

    gr
    Raymond
    RayIT


    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:80

    <VirtualHost *:80>

    DocumentRoot /www/example1
    ServerName www.example1.com

    # Other directives here


    </VirtualHost>

    <VirtualHost *:80>

    DocumentRoot /www/example2
    ServerName www.example2.org

    # Other directives here


    </VirtualHost>
     
  3. rbradshaw

    rbradshaw New Member

    by doing that it now displays the default page saying 'it works' for both domains.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Try to add ServerName directives to each vhost. If that doesn't help, check Apache's error log.
     
  5. zcworld

    zcworld New Member

    this is my vhost conf file i use


    <VirtualHost *:80>
    ServerName vdb.site.lan

    DocumentRoot /var/www/vhosts/site.lan/vdb/def/

    <Directory /var/www/vhosts/site.lan/vdb/def/>
    Options Indexes FollowSymLinks MultiViews
    </Directory>

    CustomLog /var/www/logs/def.vdb.site.lan_access.log combined
    ErrorLog /var/www/logs/def.vdb.site.lan_error.log


    </VirtualHost>


    ##############################

    <VirtualHost *:80>
    ServerName list.vdb.site.lan
    DocumentRoot /var/www/vhosts/site.lan/vdb/list/

    <Directory /var/www/vhosts/site.lan/vdb/list/>
    Options Indexes FollowSymLinks MultiViews
    </Directory>

    CustomLog /var/www/logs/list.vdb.site.lan_access.log combined
    ErrorLog /var/www/logs/list.vdb.site.lan_error.log


    if you adding this to your httpd.conf file or the defualt apache conf file

    make sure you have before any vhost
    NameVirtualHost *:80

    <vhost here >

    than restart apache and try it

    make sure you add to you /etc/host (on linux) or c:\windows\system32\etc\hosts

    IP / DNS
    192.168.1.25 vdb.site.lan
    192.168.1.25 list.vdb.site.lan



    so on
     
  6. rbradshaw

    rbradshaw New Member

    thank you all for your help, its working now
     
  7. zcworld

    zcworld New Member



    ok
    the *:80
    as far as i know
    anyname : port 80

    than the ServerName tell Apache what is the name of the Vhost
     
  8. mattg2379

    mattg2379 New Member

    Hi.

    Im sorry for posting this here. It's 'kind of' on topic, as it's a vhost issue, but relating to .htaccess. I cant find anywhere on the forum to post a new topic, so Ive had to reply to an existing one.

    My issue is this:

    I now have ISPConfig 3 set up beautifully on Ubuntu (with thanks to Falko on a previous thread), but one of my vhosts runs wordpress that uses a permalink structure. I have a .htaccess file that used to work on the old hosting environment, but whenever I include it with these contents in the root of the site, I get a 500 error. .htaccess has this in:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]

    RewriteRule ^/?([0-9]+)?/ /index.php?p=$1 [QSA]
    </IfModule>

    How can I add it in to make sure it works? Ive tried setting AllowOverride to All instead of None, Ive attempted adding parts of the rewrite rule into the Apache directives input box for the domain - nothing.. I cannot get it to work.

    Please, please help me.

    Many thanks
     
  9. falko

    falko Super Moderator Howtoforge Staff

    Any errors in Apache's error log?
     
  10. mattg2379

    mattg2379 New Member

    [Thu Jan 14 00:16:31 2010] [alert] [client 81.104.45.104] /var/www/clients/client2/web8/web/.htaccess: RewriteEngine not allowed here, referer: http://www.mydomain.com/


    and this is my conf file for the vhost:

    <Directory /var/www/domainname.com>
    AllowOverride None
    Order Deny,Allow
    Deny from all
    </Directory>

    <VirtualHost *:80>
    DocumentRoot /var/www/clients/client2/web8/web

    ServerName domainname.com
    ServerAlias www.domainname.com
    ServerAdmin [email protected]

    ErrorLog /var/log/ispconfig/httpd/domainname.com/error.log

    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 503 /error/503.html

    <Directory /var/www/domainname.com/web>
    Options FollowSymLinks
    AllowOverride Indexes AuthConfig Limit
    Order allow,deny
    Allow from all
    </Directory>
    <Directory /var/www/clients/client2/web8/web>
    Options FollowSymLinks
    AllowOverride Indexes AuthConfig Limit
    Order allow,deny
    Allow from all
    </Directory>

    # cgi enabled
    <Directory /var/www/clients/client2/web8/cgi-bin>
    Order allow,deny
    Allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /var/www/clients/client2/web8/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    # php as cgi enabled
    ScriptAlias /php5-cgi /var/www/php-cgi-scripts/web8/php-cgi-starter
    Action php5-cgi /php5-cgi
    AddHandler php5-cgi .php .php3 .php4 .php5
    <Directory /var/www/php-cgi-scripts/web8/>
    Order allow,deny
    Allow from all
    </Directory>


    </VirtualHost>
     
    Last edited: Jan 14, 2010
  11. falko

    falko Super Moderator Howtoforge Staff

    Change
    Code:
    <Directory /var/www/domainname.com>
    AllowOverride [B]None[/B]
    Order Deny,Allow
    Deny from all
    </Directory>
    to
    Code:
    <Directory /var/www/domainname.com>
    AllowOverride [B]all[/B]
    Order Deny,Allow
    Deny from all
    </Directory>
    and restart Apache. Does it work then?
     
  12. mattg2379

    mattg2379 New Member

    Thanks, still no luck


    I changed it to 'ALL' and added the .htaccess file back into the webroot, but no luck. still getting the 500 error
     
  13. falko

    falko Super Moderator Howtoforge Staff

    What's in the error log now?
     

Share This Page