LINUX平台部署apache+mod_python+django

前一篇文章写的在APACHE安装MOD_PYTHON的经过,其实挺简单,就是版本不兼容的问题.这次我大概说下部署DJANGO的过程.

先修改APACHE配置文件,使其加载mod_python模块

LoadModule python_module libexec/mod_python.so

运行命令查看

bin/httpd -M可以看到

 python_module (shared)
Syntax OK

说明apache已经成功加载mod_python.

下面我说下我的实际的环境和项目情况:

/infoware/xx/web是django程序目录

/infoware/_conf/xx/是控制django的程序还有一些配置(有些配置变量没有写在settings),这一步可以不需要,因为大多数人会直接配置settings文件的.我是在虚拟主机上操作.

–CENTOS5.2+APACHE2.2.11+PYTHON 2.4.3+MOD_PYTHON3.3.1+DJANGO 0.96

下面是apache配置文件

—————————————————-

<VirtualHost *:80>
        ServerAdmin webmaster@xxcom
        DocumentRoot “/infoware/xx/web”
        ServerName www1.xx.com
        ServerAlias www1.xx.com
        ErrorLog “/var/log/apache/xx/xx_error_log”
        CustomLog “/var/log/apache/xx/xx_access_log” common
        <Directory “/infoware/xx/web”>
            Options Indexes FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all

        </Directory>
        <Location “/”>
            SetHandler python-program
            PythonHandler django.core.handlers.modpython
            PythonPath “['/infoware/xx/web']+['/infoware/_conf/xx] + sys.path”
            SetEnv DJANGO_SETTINGS_MODULE settings
            SetEnv PYTHON_EGG_CACHE /tmp/cucrm//这儿是加个变量,会在下面说明
            PythonDebug On
        </Location>
</VirtualHost>

——————————————————————

以上配置一定要注意环境变量的配置,否则会出错!

我在配置前出现了以下错误,##################################################################
Can’t extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: ‘/root/.python-eggs’ The Python egg cache directory is currently set to: /root/.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory.
#################################################################

解决方法就是加环境变量

SetEnv PYTHON_EGG_CACHE /tmp/cucrm//这个目录的权限属主一定要设为APACHE指定的用户,要不就777

还有另外一种解决方法,这个我没有测试,有兴趣可以去测试.网址是:

http://www.mangbar.com/document/5d023b211579e01001157eac96e30753

大概就这样,仅供参考,如果觉得麻烦的话建议FASTCGI,这个简单点.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值