CentOS 7部署django運行環境

1,安裝postgresql數據庫,安裝過程參考個人java

2,安裝apache服務器python

sudo yum install httpd

3,安裝mod_wsgi,支持參考網上的。git

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

 mod_wsgi下載網址:web

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

看了下,該項目託管在github,我使用了當前最新的版本數據庫

按照裏面的Readme,發現有多種方法安裝,其中最簡單的爲兩種:express

1,python setup.py installapache

2, pip install mod_wsgidjango

在安裝時報錯,提示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,這樣全部的靜態文件所有彙總到一個文件夾了。

相關文章
相關標籤/搜索