CentOS 7部署django运行环境

1,安装postgresql数据库,安装过程参考我的

2,安装apache服务器

sudo yum install httpd

3,安装mod_wsgi,支持参考网上的。

https://code.google.com/p/modwsgi/wiki/InstallationOnLinux

 mod_wsgi下载网址:

http://modwsgi.readthedocs.org/en/master/

看了下,该项目托管在github,我使用了当前最新的版本

按照里面的Readme,发现有多种方法安装,其中最简单的为两种:

1,python setup.py install

2, pip install mod_wsgi

在安装时报错,提示apxs 没有安装,安装apxs的命令为

sudo yum install httpd-devel
sudo yum install gcc
sudo yum install python-devel

wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.3.2.tar.gz
python setup.py install
#测试mod_wsgi是否安装成功
 mod_wsgi-express start-server

4,集成django

https://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

开始安装django,

可以使用应用的req

sudo yum install postgresql-devel
sudo pip install -U -r req.txt

我的httpd 2.4
WSGIScriptAlias / /home/web/sysencrypt/django.wsgi

<Directory "/home/web/sysencrypt/static">
           Require all granted
</Directory>

<Directory "/home/web/">
       Require all granted
</Directory>

Alias /static/ /home/web/sysencrypt/static/

刚刚学习django,在部署到正式环境时,可以使用执行下collectstatic,这样所有的静态文件全部汇总到一个文件夹了。


你可能感兴趣的:(django)