Ist es möglich, Ihre Website mit einem anderen Sicherungsserver zu synchronisieren und dieselben .htaccess-Dateien zu verwenden?

841
stephenmm

Ich versuche, rsync zu verwenden, um alle Dateien von einem Webserver auf einen anderen Server zu replizieren, der als Backup dienen könnte, wenn der erste ausfällt. Das Problem, das ich habe, ist, dass die .htaccess-Datei erfordert, dass die AuthUserFile über den vollständig quallifizierten Pfad zur .htpasswd-Datei verfügt, und dass die Pfade auf den beiden Computern nicht gleich sind.

Weiß jemand, wie ich dieselbe .htaccess-Datei auf zwei verschiedenen Servern verwenden kann?

Vielen Dank für jede Hilfe, die zur Verfügung gestellt werden kann.

1

3 Antworten auf die Frage

4
Igor Zinov'yev

Yet another way to do it is to specify an exclude pattern, so that rsync won't touch the .htaccess file.

rsync --exclude-from=/home/user/.rsync/exclude.pat ... 

And the exclude.pat file should be in this format:

- /.htaccess - .htaccess 

The first entry will tell rsync to exclude only the root .htaccess, the second one - to exclude all .htaccess files within the synchronisation tree. You can look it up in the rsync manual.

3
Ignacio Vazquez-Abrams

One option is to use a database for your authdb instead of a file via e.g. mod_auth_mysql. This completely mitigates the need to specify any sort of a filename.

Das hört sich nach dem richtigen Weg an. Ich habe auf eine weniger aufwendige Lösung gehofft, aber das scheint definitiv die richtige Antwort zu sein. stephenmm vor 13 Jahren 0
Als zusätzlichen Bonus können Sie die authdb auch einfach über das Web bearbeiten. Ignacio Vazquez-Abrams vor 13 Jahren 0
2
bubu

If you have shell access i think a simple sed/awk command after the rsync operation to change the path.

e.g.

sed s/tommy/joe/ < .htaccessSiteA > .htaccess

for more information, man sed or http://www.grymoire.com/Unix/Sed.html