django部署实录

阿里云使用apache+mod_wsgi进行django的部署

最终救星:http://blog.chedushi.com/archives/4692

1、

http://www.it165.net/admin/html/201312/2234.html

使用了virtualhost:同一个ip使用不同的端口来serve不同的网站(apache官方文档有示例)

Running different sites on different ports.

You have multiple domains going to the same IP and also want to serve multiple ports. The example below illustrates that the name-matching takes place after the best matching IP address and port combination is determined.

Listen 80

Listen 8080

<VirtualHost 172.20.30.40:80>

ServerName www.example.com

DocumentRoot /www/domain-80

</VirtualHost>

<VirtualHost 172.20.30.40:8080>

ServerName www.example.com

DocumentRoot /www/domain-8080

</VirtualHost>

<VirtualHost 172.20.30.40:80>

ServerName www.example.org

DocumentRoot /www/otherdomain-80

</VirtualHost>

<VirtualHost 172.20.30.40:8080>

ServerName www.example.org

DocumentRoot /www/otherdomain-8080

</VirtualHost>

http://greybeard.iteye.com/blog/1564975l里面有

WSGIScriptAlias / "/usr/bigbang/stargazerservice/django.wsgi"

于是我在<VirtualHost 121.40.135.166:8080>(第二个端口的网站)里面加入:

WSGIScriptAlias "/" "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/zzc/zzc/zzc/wsgi.py"

<VirtualHost 121.40.135.166:8080>中添加:

Alias "/static/" "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/zzc/zzc/static/"

直接将static url作为目录来处理,这样子访问里面所有的文件都由服务器作为静态文件处理,于是就搞定了!

大概解决过程是这样,原理之后再补。

其他记录:

1、

Apache Virtual Host documentation

里面有apache的两种虚拟主机方案:

  • Name-based Virtual Hosts (More than one web site per IP address)
  • IP-based Virtual Hosts (An IP address for each web site)

一般选择使用name-based的,这样可以节省珍贵的ip资源

name-based可以通过开启:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

和:

Include conf/extra/httpd-vhosts.conf

并且通过:

listen port1

listen port2

lisetn ….

开启!

2、http://www.neoease.com/apache-virtual-host/ 开启virtual host的方式

3、git版本管理可以让你不记得之前可以运行的代码已经没有了的时候可以上去版本库去看!

4、urlpattern有什么用?看django文档:

This helper function will only work if DEBUG is True and your STATIC_URL setting is neither empty nor a full URL such as http://static.example.com/.

5、This directive currently has no effect.。。。。。。。。。。。

6、mod_wsgi分析:

http://a-journey-into-python-source.readthedocs.org/en/latest/100.html  超级具体的分析

WSGI: 一个协议,描述通用服务器与python app之间的接口规范

wsgi app:遵守wsgi规范的python app

mod_wsgi: apache服务器的一个扩展模块, wsgi协议在apache服务器上的一个实现,有了它, 你就可以在apache上运行wsgi app

总的来说,WSGIScriptAlias 模式,python解释器被嵌入到apache进程当中,请求处理代码是在apache的 worker子进程中执行。WSGIDaemonProcess python解释器运行在单独的进程之中,和apache进程是隔离的。

http://a-journey-into-python-source.readthedocs.org/en/latest/index.html# 已suck

7、记得自定义virtualhost写各个端口的errorlog和customlog文件

时间: 2024-08-08 03:45:11

django部署实录的相关文章

Django部署:Django+gunicorn+Nginx环境的搭建

本人的服务器环境为Ubuntu14.04,使用的是Python3.4版本,并且安装有pip(Ubuntu中Python3配合的是pip3),并且以管理员身份运行,如果是普通用户,请切换管理员权限(sudo). 一.gunicorn和nginx的简介 gunicorn需要搭配nginx使用,那么两者的作用到底是什么. 1.gunicorn简介:gunicorn是一个Python WSGI UNIX服务器.WSGI(Web Server Gateway Interface)是Web服务网关接口,位于

XenServer部署实录——添加共享存储

XenServer部署实录系列之04添加共享存储 作业环境 XenServer服务器 OS:XenServer 6.2 Hostname:xsr01 IP:192.168.0.241/24 Gateway:IP:192.168.0.1/24 硬件环境:Dell PowerEdge R720 NFS服务器 OS:CentOS 6.4 Hostname:nfs01 IP:192.168.0.204/24 Gateway:IP:192.168.0.1/24 运行软件:nfs,rpcbind 一.关于X

Gunicorn + Django 部署

1. 下载gunicorn pip install gunicorn 2. 运行 gunicorn AutoSa.wsgi:application ## AutoSa为我project的名字,后面的不变即可 -b 监听ip和端口,默认是 127.0.0.1:8000 如:0.0.0.0:80-w 开启多个进程 如 -w 8-k gunicorn 默认使用同步阻塞的网络模型(-k sync),对于大并发的访问可能表现不够好, 它还支持其它更好的模式,比如:gevent或meinheld. 先pip

django部署到apache上(非常重要的,3者版本要一致,是32位就都要是32位的)

网上把django部署到apache的文章挺多的,但是按照大家的操作,并没有一次就成功,还是遇到了一些问题,这里主要有以下几个情况. 1.网上找到的mod_wsgi的版本问题,导致动态库加载不上. 2.配置问题,因为涉及到apache.Python和mod_wsgi的版本,所以配置上可能也不太一样. 这里我把我遇到的问题和解决方案比较详细的写下来.失败经历可跳过. 失败经历 我的环境是python2.7.11 64位版本,apache我选择的是2.4.20x 64位版本,这里有一点必须要保证的是

Django 部署 uwsgi + nginx + supervisor

Django 部署 uwsgi + nginx + supervisor https://hacpai.com/article/1460607620615?p=1&m=0 zonghua ? 6 个月前 ? 浏览 1.7K ? 回帖 15Python  Django  uwsgi  NGINX 更新依赖 pip install uwsgi 编辑配置文件 uwsgi.ini [uwsgi] # Django-related settings chdir = /home/zonghua/Docume

XenServer部署实录——网络配置

XenServer部署实录系列之06网络配置 作业环境 XenServer服务器 硬件型号:Dell PowerEdge R720 OS:XenServer 6.2 Hostname:xsr01 Eth0 IP:192.168.0.241/24 Gateway:IP:192.168.0.1/24 三层交换机 硬件型号:Quidway S5700 VLAN信息: VLAN10网段为192.168.10.0/24,管理IP为192.168.10.1 VLAN20网段为192.168.20.0/24,

django部署到apache上

网上把django部署到apache的文章挺多的,但是按照大家的操作,并没有一次就成功,还是遇到了一些问题,这里主要有以下几个情况. 1.网上找到的mod_wsgi的版本问题,导致动态库加载不上. 2.配置问题,因为涉及到apache.python和mod_wsgi的版本,所以配置上可能也不太一样. 这里我把我遇到的问题和解决方案比较详细的写下来.失败经历可跳过. 失败经历 我的环境是python2.7.11 64位版本,apache我选择的是2.4.20x 64位版本,这里有一点必须要保证的是

django 部署,gunicorn、virtualenv、nginx

声明: 1.本篇文章是我边写命令边写的,请尊重我的劳动成果,转载请加上链接. 2.我既然公开写出来,是希望大家遇到问题的时候有个参考,所以,大家可以免费转载,使用该文章 3.但是,如果你要用这篇文章来赚钱,sorry,你至少得分我点吧. 使用gunicorn 来部署django django写代码简单,但部署是个难题,今天终于发现gunicorn 这个好东西,与大家一起分享. 环境:ubuntu 14.04 64bit + django 1.6.5 + virtualenv + gunicorn

python之Django部署

Django部署: 1. 租云服务器 2. 买服务器 租:公网IP,111.13.101.208 租域名:www.pythonav.com <-> 111.13.101.208 3. 编写代码 4. 拷贝代码到服务器[Python,Django,pymysql,sqllite] 5. settings.py ALLOWED_HOSTS = ['服务器',]  # 即网站IP python manage.py runserver 0.0.0.0:8001 使用: 遵循wsig协议: wsgire