Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: Ubuntu server + Apache + meerdere 'domeinen'  (gelezen 1916 keer)

virtualweb

  • Gast
Ubuntu server + Apache + meerdere 'domeinen'
« Gepost op: 2008/11/15, 10:48:58 »
Hée.

Ik zit nu nog op een simpel windows computertje met WAMP server (apache/php/mysql, you know). Maar nu heb ik het probleem dat ik mijn sites niet goed kan testen omdat de root nu voor elke site is:
http://localhost/'naamvandesite'/index.php
En als ik dan doe:
'/' dan komt die bij localhost en niet bij localhost/'naamvandesite'/

Nu weet ik dat je bij Windows Server het volgende kan doen:
http://localhost:8392
en dat is dan de root, en dan kan je de 4 cijfers voor elke site aanpassen.

Is zo iets ook mogelijk bij Apache of bij Ubuntu server?

Alvast bedankt!

Re: Ubuntu server + Apache + meerdere 'domeinen'
« Reactie #1 Gepost op: 2008/11/15, 12:41:38 »
Ja. Je kan voor iedere virtual host (wat jij 'domein' noemt) een andere poort opgeven in Apache2 waar naar geluisterd moet worden.

mossel

  • Gast
Re: Ubuntu server + Apache + meerdere 'domeinen'
« Reactie #2 Gepost op: 2008/11/15, 22:57:00 »
Documentatie:
http://httpd.apache.org/docs/2.0/vhosts/examples.html

You have multiple domains going to the same IP and also want to serve multiple ports. By defining the ports in the "NameVirtualHost" tag, you can allow this to work. If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.
Server configuration

Listen 80
Listen 8080

NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080

<VirtualHost 172.20.30.40:80>
ServerName www.example1.com
DocumentRoot /www/domain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example1.com
DocumentRoot /www/domain-8080
</VirtualHost>

<VirtualHost 172.20.30.40:80>
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>

Re: Ubuntu server + Apache + meerdere 'domeinen'
« Reactie #3 Gepost op: 2008/11/16, 22:14:10 »
In Ubuntu is dat vreselijk makkelijk:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/nieuwenaam.
Bewerk dan het nieuwenaam bestand en zorg voor een juiste ServerName en DocumentRoot.
Dan doe je: sudo a2ensite nieuwenaam en voila :)

Re: Ubuntu server + Apache + meerdere 'domeinen'
« Reactie #4 Gepost op: 2008/11/16, 22:16:06 »
Hier is als voorbeeld de vhost voor planet.ubuntu-nl.org:
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName planet.ubuntu-nl.org

    DocumentRoot /srv/planet
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /srv/planet>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    Alias /static /srv/static
    <Directory /srv/static>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/planet/error.log
    LogLevel warn
    CustomLog /var/log/apache2/planet/access.log combined
    ServerSignature Off
</VirtualHost>

Re: Ubuntu server + Apache + meerdere 'domeinen'
« Reactie #5 Gepost op: 2008/11/16, 22:21:40 »
Dan ook nog de *:80 vervangen door *:12345 en die poort in /etc/apache2/ports.conf zetten