Apache2 vhosts

Fórumok

Apache2 vhosts

Hozzászólások

Adott egy szerverke dinamikus ipvel. Dyn.hus hostok vannak hozzárendelve. Ezek a dyn.hu hostok apache1 alatt vhostként működtek. http://aty.tx.hu = http://medvesajt.tx.hu/~aty ; http://ranger.tx.hu = http://medvesajt.tx.hu/~ranger. Tökéletesen mentek is.
Váltottam apache2-re. Itt ugyebár a httpd.conf elég rendesen szét lett darabolva. Létezik sites-avaliable könyvtár, ide raktam a vhost confjait. Illetve egy sites-enabled, ide raktam symlinkeket a confokra.
A vhostok közül azonban mindig csak az egyik működik. Tehát medvesajt.tx.hura és ranger.tx.hura is az aty.tx.hunál meghatározott elérési út jön be.
Itt vannak a config fájljaim:

medvesajt:/etc/apache2/sites-enabled# ls -las
összesen 8
4 drwxr-xr-x 2 root root 4096 2004-12-19 17:53 .
4 drwxr-xr-x 8 root root 4096 2004-12-19 17:31 ..
0 lrwxr-xr-x 1 root root 22 2004-12-19 17:34 aty -> ../sites-available/aty
0 lrwxr-xr-x 1 root root 36 2004-12-19 17:30 default -> /etc/apache2/sites-available/default
0 lrwxr-xr-x 1 root root 25 2004-12-19 17:46 ranger -> ../sites-available/ranger

medvesajt:/etc/apache2/sites-enabled# cat aty
NameVirtualHost *:80

<VirtualHost *>
ServerAdmin root@medvesajt.tx.hu
DocumentRoot /home/aty/public_html
ServerName aty.tx.hu
CustomLog /var/log/apache2/aty.log combined
</VirtualHost>

medvesajt:/etc/apache2/sites-enabled# cat default
NameVirtualHost *:80
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

medvesajt:/etc/apache2/sites-enabled# cat ranger
NameVirtualHost *:80

<VirtualHost *>
ServerAdmin root@medvesajt.tx.hu
DocumentRoot /home/ranger/public_html
ServerName ranger.tx.hu
CustomLog /var/log/apache2/ranger.log combined
</VirtualHost>

EnRox segítségével megoldódott. Egyetlen fájlba kellett őket zsúfolni. Illetrve a Virtualhost után is *:80 kell * helyett. Azonban van egy elegáns megoldás is.
1. dinamikus vhostokat alkalmazva. legkényelmesebb.

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin root@medvesajt.tx.hu
UseCanonicalName Off
VirtualDocumentRoot /home/%1/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error_%1.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/%1.log combined
ServerSignature On

Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>

2. Szimplán csak összezsúfolva.

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin root@medvesajt.tx.hu
UseCanonicalName Off
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

<VirtualHost *:80>
ServerAdmin root@medvesajt.tx.hu
DocumentRoot /home/ranger/public_html
ServerName ranger.tx.hu
CustomLog /var/log/apache2/ranger.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin root@medvesajt.tx.hu
DocumentRoot /home/aty/public_html
ServerName aty.tx.hu
CustomLog /var/log/apache2/aty.log combined
</VirtualHost>

Üdv.

Szeretnék olyat, hogy a mappa a virtualhost, így új weboldal esetén gyakorlatilag elég az ftp felhasználót és a mysql felhasználót beállítani, viszont ez a felállás:

VirtualDocumentRoot /usr/local/www/%-1/%-2/%-3/%-4/

nem jó, mert nekem úgy vannak a domainek hogy:

Ezzel semmi baj csak a mihez tartás végett:

aldomain.belsonet.cc.cc /usr/local/www/cc/cc/belsonet/aldomain
www.aldomain.belsonet.cc.cc /usr/local/www/cc/cc/belsonet/aldomain

Még ez is jó:

aldomain.belsonet.hu /usr/local/www/hu/belsonet/aldomain/_/

Itt kezdődik a probléma, ennek már kell a www mappa:

www.aldomain.belsonet.hu /usr/local/www/hu/belsonet/aldomain/www

a lényege tehát az írásnak, hogy nem akarok ssh-n belépni és symlinkelni mindent az /usr/local/www/hu/belsonet/aldomain/_/ -ból a /usr/local/www/hu/belsonet/aldomain/www -be hogy ez így működhessen és a www-t a nem www-s domainre irányítani rewrite-vel sem túl szerencsés. Tud erre mondani valaki megoldást? Nem teszek sql-ből virtualhostot meg nem cserélek lighttpd-re sem és a google-t is néztem már. Köszi.