• 17
  • Jan

东转转,西转转,还是HostMonster最亲切!

之前用的是Webfaction的mod_wsgi,转移回HostMonster的fastcgi居然不会配置了!结果走了很多弯路,以后一定要做笔记啊!

首先,下面是基本结构:

imtx.cn/

--------imtx.cn/

--------cgi-bin/imtxcn.fcgi

--------.htaccess

--------media@

--------static@

imtxcn.fcgi的内容是:

#!/path-to-python

import os
import sys

# Add a custom Python path.

sys.path.insert(0, "/path-to-imtx.cn")

# Switch to the directory of your project. (Optional.)
os.chdir("/path-to-imtx.cn")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "imtx.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

.htaccess的内容是:

AddHandler fcgid-script .fcgi

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.imtx.cn [OR]
RewriteCond %{HTTP_HOST} ^imtx-cn.gnome-tweak.com1
RewriteRule ^(.*)$ "http\:\/\/imtx\.cn/$1" [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/imtxcn.fcgi/$1 [QSA,L]

值得注意的是第一行,并不是“fastcgi-script”,而是“fcgid-script”,如果是前者,会直接把脚本打印出来。具体原因不详。

最后两个静态目录“media”和“static”,直接链接就可以了,我之前还傻傻地折腾Rewrite去了。

» You can leave a comment.

7 Comments

  1. 额,有搬家啊,不折腾VPS了~

  2. nginx笑了...
    如果是nginx+django的話,性能會到達什麼地步呢


  3. $ grep imtx /etc/hosts
    174.120.139.134 imtx.cn

  4. skee

    不是停止解析了吗?DNS怎么改的呢?

  5. 你好!
    我的hostmonster host目录traceroot到超时了,页面打不开... 请问是咋回事呢?

Leave a Comment