码迷,mamicode.com
首页 > 编程语言 > 详细

apache部署mo_python

时间:2014-08-28 21:06:46      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   strong   ar   for   

 

一,安装 mod_wsgi

sudo apt-get install apache2-threaded-dev

sudo apt-get install apache2 libapache2-mod-wsgi

django 最新版已经不支持mod_python,所以mod_wsgi是最好的选择

 

增加apache配置端口:

  修改/etc/apache/site-available/python

  

<VirtualHost *:801>
    ServerAdmin webmaster@localhost
    
    DocumentRoot /var/www/python/
    <Directory />
        Options FollowSymLinks
        AllowOverride ALl
    </Directory>
    <Directory /var/www/python>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    
    WSGIScriptAlias / "/var/www/python/server/server/wsgi.py"


    ErrorLog ${APACHE_LOG_DIR}/py.error.log

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

    CustomLog ${APACHE_LOG_DIR}/py.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/ports.conf

  使配置生效:sudo a2ensite python

  进入/var/www/python

  django-admin.py startproject server

  修改var/www/python/server/server/wsgi.py 加入环境变量:

  

"""
WSGI config for server project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""
import os
import sys

path = /var/www/python/server
if path not in sys.path:
    sys.path.append(path)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

 

打开网址查看效果:

  localhost:801

 

apache部署mo_python

标签:style   blog   http   color   os   io   strong   ar   for   

原文地址:http://www.cnblogs.com/canbefree/p/3942330.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!