2011-11-18 128 views
1

經過幾個小時的嘗試在我的專用根服務器上設置子域名後,我向你尋求幫助。在debian上用apache創建子域名;作爲第二步創建hgweb子域

目標:

  • 能夠創建和訪問子域
  • 建立一個自己的子域善變庫,使用hgweb

有關服務器的信息:

  • 的Debian Linux,Kernel 2.6.32-028stab094.3
  • 的Apache/2.2.16(Debian的)
  • 水銀1.6.4
  • 中的libapache2-MOD-WSGI-PY 3安裝

第一個問題:什麼是錯我的Apache的配置,我不能訪問我的子域通過瀏覽器?

其實,我可以訪問根域和安裝在那裏的網站。

我的配置: 的/ etc/apache2的/網站可用/默認

<VirtualHost *> 
    ServerAdmin [email protected] 
    ServerName mydomain.tld 
    ServerAlias www.mydomain.tld 

    DocumentRoot /var/www/forum 
    <Directory /> 
      Options FollowSymLinks 
      AllowOverride None 
    </Directory> 
    <Directory /var/www/forum> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride None 
      Order allow,deny 
      allow from all 
    </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 ${APACHE_LOG_DIR}/error.log 

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

    CustomLog ${APACHE_LOG_DIR}/access.log combined 

    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> 

/etc/apache2/sites-available/hgrepos.domainname.tld

<VirtualHost *> 
    ServerName hgrepos.domainname.tld 
    ServerAlias www.hgrepos.domainname.tld 
    DocumentRoot /var/www/hgrepos/htdocs 

    # WSGIScriptAliasMatch ^(.*)$ /var/www/hgrepos/cgi-bin/hgweb.wsgi$1 
    WSGIScriptAlias//var/www/hgrepos/cgi-bin/hgweb.wsgi 

    # To enable "daemon" mode, uncomment following lines. (Read mod_wsgi docs for more info) 
    # WSGIDaemonProcess hgrepos.domainname.tld user=USER group=GROUP threads=1 processes=15 maximum-requests=1000 
    WSGIDaemonProcess hgrepos.domainname.tld threads=1 processes=15 maximum-requests=1000 
    # some more interesting options (tested on mod_wsgi 2.0): 
    # umask=0007 display-name=wsgi-hg.example.net inactivity-timeout=300 
    # WSGIProcessGroup hg.example.net 

    <Directory /var/www/hgrepos/htdocs> 
     Options FollowSymlinks 
     DirectoryIndex index.html 

     AllowOverride None 
     Order allow,deny 
     Allow from all 
    </Directory> 

    <Directory /var/www/hgrepos/cgi-bin> 
     Options ExecCGI FollowSymlinks 

     AddHandler wsgi-script .wsgi 

     AllowOverride None 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

我的/etc/apache2/httpd.conf文件爲空。

我通過a2ensite subdomain.domainname.tld啓用了子域文件。

[email protected]:/etc/apache2/sites-available# ll ../sites-enabled/ 
lrwxrwxrwx 1 root root 26 Oct 29 22:33 000-default -> ../sites-available/default 
lrwxrwxrwx 1 root root 48 Nov 17 00:41 hgrepos.domainname.tld -> ../sites-available/hgrepos.domainname.tld 

我同時使用,/etc/init.d/apache2 reload/etc/init.d/apache2 restart。 Apache沒有告訴我,我試圖加載格式錯誤的配置。

根域的網站位於​​之下並且可以訪問。

我對在/ var/WWW/hgrepos文件夾結構是這樣的:

hgrepos 
+- drwxr-xr-x www-data www-data cgi-bin 
|--- -rwxr-xr-x www-data www-data hgweb.config 
|--- -rwxr-xr-x www-data www-data hgweb.wsgi 
+-- drwxr-xr-x htdocs 
|--- -rw-r--r-- www-data www-data index.html 
|--- drwxr-xr-x www-data www-data myFirstHgRep 

index.html文件只包含一些世界,你好! html來查看該子域是否可訪問。

現在回到我的第一個問題:爲什麼我不能通過我的瀏覽器訪問hgrepos子域?

現在,我想爲我的私人項目提供一些mercurial(hg)存儲庫,使用hgweb。我跟着這些指示:
https://www.mercurial-scm.org/wiki/modwsgi
https://www.mercurial-scm.org/wiki/HgWebDirStepByStepFtpOnly

這裏正在在/ var/WWW/hgrepos/cgi-bin目錄/我的配置文件:

hgweb.wsgi

#!/usr/bin/env python 
# 
# An example hgweb CGI script, edit as necessary 
# See also https://www.mercurial-scm.org/wiki/PublishingRepositories 

# Path to repo or hgweb config to serve (see 'hg help hgweb') 
# config = "hgweb.config" 

# Uncomment and adjust if Mercurial is not installed system-wide: 
#import sys; sys.path.insert(0, "/path/to/python/lib") 

# Uncomment to send python tracebacks to the browser if an error occurs: 
import cgitb; cgitb.enable() 

from mercurial import demandimport; demandimport.enable() 
from mercurial.hgweb import hgweb, wsgicgi 
application = hgweb("hgweb.config") 
#wsgicgi.launch(application) 

hgweb.config

[web] 
style = coal 
baseurl = 

[paths] 
/= /var/www/hgrepos/htdocs/* 

文件的權利:

[email protected]:/var/www/hgrepos/cgi-bin# ll 
-rwxr-xr-x 1 www-data www-data 68 Nov 17 01:16 hgweb.config 
-rwxr-xr-x 1 www-data www-data 621 Nov 17 01:24 hgweb.wsgi 

所以現在我的第二個問題:我怎樣才能得到hgweb工作?我的配置有什麼問題?

那麼,哇,這是很多文字,但我不太確定哪些信息是需要的,哪些不是。希望你能幫助我,任何提示都有幫助:)

+1

我沒有時間查看完整的配置,但一個簡單的問題,子域的DNS解析呢?您的DNS服務器是否配置爲迴應關於您的子域名的請求? – krtek

+0

噢,你是對的,謝謝你的提示。至少這是失蹤,我會告訴你,如果這解決了這個問題, – bully

+0

謝謝krtek,這至少解決了我的第一個問題 - 我無法訪問我的子域名!太好了謝謝!現在我需要修復hgweb-stuff ... – bully

回答

1

好吧,好消息 - 我解決了我的問題。

第一步是去除的libapache-MOD-WSGI-PY 3和安裝中的libapache-MOD-WSGI(在我嘗試我重新安裝了WSGI-PY 3包好幾次,似乎是固定的,不知怎的,我的最後重新安裝.. 。)

apt-get remove libapache2-mod-wsgi-py3 
apt-get install libapach2-mod-wsgi-py3 
apt-get autoremove 

之後,重新啓動Apache的讓我在我的error.log中以下內容:

mod_wsgi (pid=16349): Target WSGI script '/var/www/hgrepos/cgi-bin/hgweb.wsgi' cannot be loaded as Python module. 
mod_wsgi (pid=16349): Exception occurred processing WSGI script '/var/www/hgrepos/cgi-bin/hgweb.wsgi'. 
Traceback (most recent call last): 
    File "/var/www/hgrepos/cgi-bin/hgweb.wsgi", line 20, in <module> 
    application = hgweb("/var/www/hgrepos/cgi-bin/hgweb.config") 
    File "/usr/lib/pymodules/python2.6/mercurial/hgweb/hgweb_mod.py", line 32, in __init__ 
    self.repo = hg.repository(u, repo) 
    File "/usr/lib/pymodules/python2.6/mercurial/hg.py", line 94, in repository 
    repo = _lookup(path).instance(ui, path, create) 
    File "/usr/lib/pymodules/python2.6/mercurial/bundlerepo.py", line 305, in instance 
    return bundlerepository(ui, repopath, bundlename) 
    File "/usr/lib/pymodules/python2.6/mercurial/bundlerepo.py", line 177, in __init__ 
    raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename) 
Abort: /var/www/hgrepos/cgi-bin/hgweb.config: not a Mercurial bundle file 

this,我建立了我的hgweb.wsgi文件是這樣的:

#!/usr/bin/env python 
# 

# Uncomment and adjust if Mercurial is not installed system-wide: 
#import sys; sys.path.insert(0, "/usr/lib/pymodules/python2.6") 

# Uncomment to send python tracebacks to the browser if an error occurs: 
import cgitb; cgitb.enable() 

from mercurial import demandimport; demandimport.enable() 
from mercurial.hgweb import hgweb, wsgicgi 

# Path to repo or hgweb config to serve (see 'hg help hgweb') 
config = "/var/www/hgrepos/cgi-bin/hgweb.config" 
application = hgweb(config) 

重啓動Apache

/etc/init.d/apache2 restart 

現在一切對我的作品。

再次感謝krtek,他真的幫助了我的痛苦!做我的一天:D