标签:
一、软件安装
1.升级linux中的python 参考“centos升级python”
2.安装apache(httpd)
3.安装django,先要安装setuptools 参考“安装django 提示ImportError: No module named setuptools”
4.安装mod_wsgi 参考centos安装mod_wsgi
5.安装mysql
二、先安装一些包,否则会运行不起来
1.#yum install -y mysql mysql-server gcc python-devel mysql-devel gcc-c++
2.安装mysql-python包,见附件,下载地址:http://sourceforge.net/projects/mysql-python/files/
#python setup.py build
(
如果遇到/usr/bin/ld: cannot find -lpython2.7,那是没有添加软链接
#ln -s /usr/local/python27/lib/libpython2.7.so /usr/lib64/libpython2.7.so (64位系统)
或者
#ln -s /usr/local/python27/lib/libpython2.7.so /usr/lib/libpython2.7.so (32位系统)
参考:http://www.lvtao.net/tool/python-mysqldb-for-python.html
)
3.安装redis-py
#python setup.py install
三、部署
1.将django站点拷贝到/var/www/html中
2.修改settings.py
修改ROOT_URLCONF="urls"
在末尾加上TEMPLATE_DIRS=(‘/var/www/html/dockerApp/app/templates‘,)
3.修改wsgi.py,如下图
4.修改apache配置文件(/etc/httpd/conf/httpd.conf),在末尾加上
LoadModule wsgi_module modules/mod_wsgi.so
<VirtualHost *:80>
DocumentRoot /var/www/html/dockerApp/
<Directory /var/www/html/dockerApp/app>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /var/www/html/dockerApp/dockerApp/wsgi.py
</VirtualHost>
5.添加否则会报500,提示没有权限进入文件夹
#mkdir /var/www/.python-eggs
#chmod -R 777 /var/www/.python-eggs
6.重启apache,#service httpd restart
*****注意在代码中调用模版处,前面不要加上路径,要么会找不到模版*****
附件:
https://app.yinxiang.com/shard/s41/res/a645e971-adba-4385-adac-e6b300732f52/MySQL-python-1.2.3.tar.gz
django 安装/部署过程
标签:
原文地址:http://www.cnblogs.com/biboxie/p/4233340.html