【发布时间】:2012-01-01 16:39:13
【问题描述】:
经过数小时尝试在我的专用根服务器上设置子域后,我向您寻求帮助。
目标:
- 能够创建和访问子域
- 使用 hgweb 为 mercurial 存储库设置自己的子域
服务器信息:
- Debian Linux,内核 2.6.32-028stab094.3
- Apache/2.2.16 (Debian)
- Mercurial 1.6.4
- 已安装 libapache2-mod-wsgi-py3
第一个问题:我的 apache 配置出了什么问题,我无法通过浏览器访问我的子域?
实际上,我可以访问根域和安装在那里的站点。
我的配置: /etc/apache2/sites-available/default
<VirtualHost *>
ServerAdmin webmaster@localhost
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 启用了子域文件。
regine@diddi:/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/forum 下并且可以访问。
/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 文件只包含一些 Hello World! 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/*
文件的权利:
regine@diddi:/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 正常工作?我的配置到底有什么问题?
嗯,哇,这是很多文字,但我不太确定需要哪些信息,哪些不需要。希望你能帮助我,任何提示都有帮助:)
【问题讨论】:
-
我没有时间看完整的配置,但是一个快速的问题,子域的 DNS 解析怎么样?您的 DNS 服务器是否配置为响应有关您的子域的请求?
-
哦,你是对的,谢谢你的提示。至少这是缺失的,如果这也解决了问题,我会通知你
-
谢谢krtek,这至少解决了我的第一个问题——我无法访问我的子域!太好了谢谢!现在我需要修复 hgweb-stuff...
-
很高兴我能帮上忙...如果我今天有时间我会试着看看你的配置问题。
-
嘿krtek,会很不错。我现在正在处理它,但我仍然收到 500 内部服务器错误。我会看一下日志并重试一下,我会在有消息时立即通知您。
标签: apache mercurial subdomain hgweb