Linux - Server Administration: Unterschied zwischen den Versionen
| Zeile 1: | Zeile 1: | ||
== Linux Server mit Plesk == | == Linux Server mit Plesk == | ||
| + | Quick Info: | ||
| + | |||
| + | Apache Konfiguration Testen: | ||
| + | apache2ctl configtest | ||
| + | |||
| + | Apache Neu starten: | ||
| + | apache2ctl -k restart | ||
| + | |||
| + | Plesk vhost.conf neu einlesen: | ||
| + | /usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.com | ||
| + | |||
| + | oder für alle sites | ||
| + | |||
| + | /usr/local/psa/admin/bin/websrvmng -a. | ||
| + | |||
Plesk legt die Domains in eigenen vhosts an und liest und schreibt dort jeweils eine eigene httpd.conf für den Apache. Ändert man dort etwas kann das bei der nächste Änderung über Plesk wieder überschrieben werden. | Plesk legt die Domains in eigenen vhosts an und liest und schreibt dort jeweils eine eigene httpd.conf für den Apache. Ändert man dort etwas kann das bei der nächste Änderung über Plesk wieder überschrieben werden. | ||
Version vom 12. Dezember 2008, 17:35 Uhr
Linux Server mit Plesk
Quick Info:
Apache Konfiguration Testen:
apache2ctl configtest
Apache Neu starten:
apache2ctl -k restart
Plesk vhost.conf neu einlesen:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.com
oder für alle sites
/usr/local/psa/admin/bin/websrvmng -a.
Plesk legt die Domains in eigenen vhosts an und liest und schreibt dort jeweils eine eigene httpd.conf für den Apache. Ändert man dort etwas kann das bei der nächste Änderung über Plesk wieder überschrieben werden.
hier gab es einen schönen Ansatz: Quelle: http://www.schreinert.com/eigenen-apache-config-anlegen-plesk-per-vhostconf-50/ (12.12.2008)
Eigenen Apache-Config anlegen: Plesk per vhost.conf
Plesk als Server-Management-Software schreibt und überschreibt die Konfugrationsdateien des Apache-Web-Servers mit jeder Änderung der entsprechenden Plesk-Einstellungen. Das heißt, dass es nicht ratsam ist, die Apache-Konfiguration httpd.conf nachträglich per Editor anzupassen. Damit doch eigene Änderungen an den Domain-Einstellungen möglich sind, bietet Plesk die vhost.conf - Datei an, welche aber nicht ohne weiteres aktiv ist.
Für ergänzende Konfigurations-Anweisungen des Apaches sind die folgenden beiden Schritte notwendig:
1. Anlegen der vhost.conf für die gewünschte Domain.
Im Konfigurations-Verzeichnis der Domain liegt von Haus aus die Datei httpd.conf, welche von Plesk gelesen und geschrieben wird. Das Konfigurationsverzeichnis für die Domain www.domain.de liegt beispielsweise bei SuSE Linux hier: /srv/www/vhosts/domain.de/conf/. In dieses Verzeichnis gehört nun die vhost.conf - Datei, in die die Apache-Einstellungen eingetragen werden können. Alle Einträge sind dabei automatisch innerhalb der <Virtual> Konfiguration enthalten. Anschließend noch daran denken, die vhost.conf für den Web-Server lesbar zu machen:
$> chmod go+r /srv/www/vhosts/domain.de/conf/vhost.conf
2. Plesk dazu bringen, die vhost.conf Datei einzubinden.
Auch wenn die eigenen Einstellungen in der Datei bereits korrekt eingetragen sind, so weiß der Apache noch nichts von der erweiterten Konfiguration. Plesk muss zuvor noch die Datei in die bestehende httpd.conf per Include einbinden. Dies kann hervorgerufen werden, indem die Einstellungen zu der Domain in Plesk aufgerufen und (unverändert) gespeichert werden.
Jetzt ist die vhost.conf in der httpd.conf inkludiert und dem Apache bekannt gegeben.
Noch ein Tipp für Änderungen an der Konfiguration: Die geänderte Konfiguration sollte immer überprüft werden, bevor der Apache neu gestartet wird — egal ob per rcapache restart oder apache2ctl graceful. Bei Fehlern droht sonst, dass der Apache seinen Dienst verweigert.
Daher immer ein apache2ctl configtest vor dem “reload” durchführen
Ende des Zitats
Ein weiterer Artikel bringt noch mehr Licht ins Dunkel:
Wondering how to create a good vhost.conf?
Well you’ve come to the right place.
Quelle: http://www.gadberry.com/aaron/2006/02/09/plesk_vhost/ (12.12.2008)
Using Plesk and vhost.conf
9th February 2006 - By Aaron
Plesk automatically updates httpd.include for each domain, making changes to this file only temporary. You don’t want to use this file if you need to make changes to Apache’s config on the fly, such as php’s open_basedir values per domain.
Instead you will want to use a vhost.conf file. This file will be placed inside your domain’s conf directory, usually found at /var/www/vhosts/yourdomain.com/conf. Create a file called vhost.conf in whatever editor you prefer. I use joe.
You can now put in any Apache configuration options like you would into httpd.include. In my case I wanted to do three things, give my site access to /php/includes, add a mod_rewrite rule, and tell Apache to follow symlinks.
Here is my resulting vhost.conf file.
<Directory /var/www/vhosts/yourdomain.com/httpdocs/> php_admin_value open_basedir "/var/www/vhosts/yourdomain.com/httpdocs:/php/includes" </Directory> Options +FollowSymLinks RewriteEngine on RewriteRule /ministries/(.*)\.php$ /ministries/ministry.php?url=$1
And some annotations from users about a redirection:
You probably need to edit your vhost.conf of the redirected domain to include the httpdocs of the first domain, such as
php_admin_value open_basedir "/var/www/vhosts/redirecteddomain.com/httpdocs:/var/www/vhosts/firstdomain.com/httpdocs"
I did this same thing for a while. I would encourage you instead to just send a php header redirect with a “permenantly moved” header. The search engines will drop your second site off the listings either way. They don’t play friendly with mirrors. You can see the first three lines take care of the additional base directory for php, the line after the empty one takes care of following symlinks, and the last two lines turn on the rewrite engine and add a rule to it.
Save your file and we’re almost done. This is the part that everyone forgets, you need to tell Plesk to update it’s information. See your httpd.include file will soon have an include for your vhost.conf, but it doesn’t yet. Plesk has to realize it’s there and then add the include. The command to reconfigure Plesk for one site is
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.com
or the command I use reconfigures all sites,
/usr/local/psa/admin/bin/websrvmng -a.
After running that there is no need to restart Apache or any other service. Your changes should have taken effect already.
Another Post:
If you need to add more directories try this:
php_admin_value open_basedir “**Directory 1**:**Directory 2**”
Vhost mit Header 301 komplett weiterleiten
von http://www.robo47.net/faq/vhost--301-header-weiterleitung (12.12.2008)
Mit diesem Code in einem Vhost spart man sich unnötige Ordner auf der Festplatte, wenn man diese eh nur Weiterleiten will.
<VirtualHost *:80> ServerName subdomain.domain.tld RedirectMatch 301 (.*) http://www.domain2.tld </VirtualHost>
Es werden auch Aufrufe von subdomain.domain.tld/asdf/ oder anderen Dokumenten und unterordnern automatisch auf die andere Domain weitergeleitet an die passende URL weitergeleitet, sprich aus subdomain.domain.tld/asdf/ wird www.domain2.tld/asdf/. Wenn man das nicht will muss man nur das weglassen und alles auf die Hauptdomain weitergeleitet.
<VirtualHost *:80> ServerName subdomain.domain.tld RedirectMatch 301 (.*) http://www.domain2.tld </VirtualHost>
Plesk Infos
Ein paar gesammelte Infos (ungeprüft)
/opt/psa/admin/conf/php.ini die PHP Einstellungen für den Admin (nicht für die Kunden !!!)
Änderungen für die Kundeneinstellungen finden in der vhost.conf im Kundenverzeichnis statt