Apache-Httpd

帶有 apache2 配置路徑錯誤的 SVN

  • December 6, 2017

我剛剛svn通過 https (with apache2) 進行了配置。我可以svn checkout,但是送出失敗了。我可以從apache2日誌中看到,svn伺服器正在錯誤的位置查找用於執行送出的儲存庫。這是我的apache2443.example.com.conf 文件:

<IfModule mod_ssl.c>
   <virtualhost *:443>
   # requests to https://example.com land here
   ServerName example.com
   DocumentRoot /home/me/svn-repos

   # global properties for all directories in this site
   <Location />
       # do not use .htaccess files
       allowoverride none
       #DirectoryIndex index.html
       #require all granted                                                                                    

       DAV svn
       SVNParentPath /home/me/svn-repos
       AuthType Basic
       AuthName "svn repositories"
       AuthUserFile blah.passwd
       #<LimitExcept GET PROPFIND OPTIONS REPORT>
       Require valid-user
       #</LimitExcept>
   </Location>

   SSLEngine On
   SSLCertificateFile blah
   SSLCertificateKeyFile blah

   <FilesMatch "\.(cgi|shtml|phtml|php)$">
           SSLOptions +StdEnvVars
   </FilesMatch>

   ErrorDocument 400 /index.html
   ErrorDocument 401 /index.html
   # lots more ErrorDocument entries

   </virtualhost>
</IfModule>

請注意,我所有的svn儲存庫都在/home/me/svn-repos(例如/home/me/svn-repos/repo1,,/home/me/svn-repos/repo2等)下的目錄中

因此,我查看了我的一個儲存庫的新本地副本:

$ cd /tmp
$ svn co --username me https://example.com/repo1 repo1
Authentication realm: <https://example.com:443> svn repositories
Password for 'me': ***

A repo1/file1.txt
Checked out revision 1.

到現在為止還挺好。但是當我嘗試送出時:

$ touch file2.txt
$ svn add file2.txt
A     file2.txt
$ svn ci file2.txt -m added
Authentication realm: <https://example.com:443> svn repositories
Password for 'me': ***

Adding         file2.txt
svn: E175009: Commit failed (details follow):
svn: E175009: The XML response contains invalid XML
svn: E130003: Malformed XML: no element found

我可以從apache2錯誤日誌中看到svn伺服器在錯誤的位置尋找儲存庫:

$ sudo tail -4 /var/log/apache2/error.log
[Sat Dec 02 20:23:29.626227 2017] [:error] [pid 123] (20014)Internal error (specific information not available): [client x.x.x.x:x] Can't open file '/home/me/svn-repos/index.html/format': Not a directory
[Sat Dec 02 20:23:29.626264 2017] [dav:error] [pid 123] [client x.x.x.x:x] Could not fetch resource information.  [404, #0]
[Sat Dec 02 20:23:29.626272 2017] [dav:error] [pid 123] [client x.x.x.x:x] Could not find the requested SVN filesystem  [404, #20]
[Sat Dec 02 20:23:29.626277 2017] [dav:error] [pid 123] [client x.x.x.x:x] Could not find the requested SVN filesystem  [404, #20]

它正在尋找的文件是/home/me/svn-repos/repo1/format,但是它沒有附加正確的路徑才能找到該文件。我懷疑這意味著我需要在我的apache2443.example.com.conf 文件中放一些東西,但我想不出是什麼。

更新

我對 443.example.com.conf 文件進行了以下更改:

# ErrorDocument 404 /index.html
ErrorDocument 404 /indexyz.html

現在,當我嘗試送出時,錯誤消息變為:

[Sat Dec 02 20:39:00.153942 2017] [:error] [pid 123] (20014)Internal error (specific information not available): [client 192.168.1.177:50228] Can't open file '/home/me/svn-repos/indexyz.html/format': No such file or directory
[Sat Dec 02 20:39:00.153979 2017] [dav:error] [pid 123] [client x.x.x.x:x] Could not fetch resource information.  [404, #0]
[Sat Dec 02 20:39:00.153987 2017] [dav:error] [pid 123] [client x.x.x.x:x] Could not find the requested SVN filesystem  [404, #2]
[Sat Dec 02 20:39:00.153992 2017] [dav:error] [pid 123] [client x.x.x.x:x] Could not find the requested SVN filesystem  [404, #2]

但這仍然沒有多大幫助。

我終於讓它工作了。最後它與文件根無關,它是 ErrorDocument 聲明 - 我只需要將它們從 更改/index.htmldefault. 我的最終配置如下所示:

&lt;IfModule mod_ssl.c&gt;
   &lt;virtualhost *:443&gt;
       # requests to https://example.com land here
       ServerName example.com
       DocumentRoot /home/me/svn-repos

       # global properties for all directories in this site
       &lt;Location /&gt;
           # do not use .htaccess files
           allowoverride none

           DAV svn
           SVNParentPath /home/me/svn-repos
           AuthType Basic
           AuthName "svn repositories"
           AuthUserFile blah.passwd
           Require valid-user
       &lt;/Location&gt;

       # http://svnbook.red-bean.com/en/1.7/svn.serverconfig.httpd.html
       CustomLog ${APACHE_LOG_DIR}/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION
       ErrorLog ${APACHE_LOG_DIR}/error.log

       SSLEngine On
       SSLCertificateFile fullchain.pem
       SSLCertificateKeyFile privkey.pem

       &lt;FilesMatch "\.(cgi|shtml|phtml|php)$"&gt;
               SSLOptions +StdEnvVars
       &lt;/FilesMatch&gt;

       ErrorDocument 400 default
       ErrorDocument 401 default
       ErrorDocument 402 default
       ErrorDocument 403 default
       ErrorDocument 404 default
       ErrorDocument 405 default
       ErrorDocument 406 default
       ErrorDocument 407 default
       ErrorDocument 408 default
       ErrorDocument 409 default
       ErrorDocument 410 default
       ErrorDocument 411 default
       ErrorDocument 412 default
       ErrorDocument 413 default
       ErrorDocument 414 default
       ErrorDocument 415 default
       ErrorDocument 416 default
       ErrorDocument 417 default
       #ErrorDocument 418 default
       ErrorDocument 421 default
       ErrorDocument 422 default
       ErrorDocument 423 default
       ErrorDocument 424 default
       ErrorDocument 426 default
       ErrorDocument 428 default
       ErrorDocument 429 default
       ErrorDocument 431 default
       ErrorDocument 451 default
       ErrorDocument 500 default
       ErrorDocument 501 default
       ErrorDocument 502 default
       ErrorDocument 503 default
       ErrorDocument 504 default
       ErrorDocument 505 default
       ErrorDocument 506 default
       ErrorDocument 507 default
       ErrorDocument 508 default
       ErrorDocument 510 default
       ErrorDocument 511 default
   &lt;/virtualhost&gt;
&lt;/IfModule&gt; 
  1. 你犯了所有可能的錯誤 (3/3)
  2. 你沒有讀過 SVN 書

使固定:

  • 儲存庫不能在 http-tree 內
  • SVN 位置不能在 http-host 的根目錄中
  • SVN 位置不能在 http-host 內的物理路徑中,只能在邏輯路徑中

引用自:https://unix.stackexchange.com/questions/408703