django+apache+uwsgi环境部署

–>

centos7.2

1.准备环境

yum install httpd php php-mysql mariadb-server -y

yum install python-pip -y

2.pip加速

mkdir ~/.pip

vim ~/.pip/pip.conf

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

3、下载mezzanine并使用

pip install mezzanine

创建mezzanine项目

mezzanine-project jyl

cd jyl/

python manage.py createdb

vi local_settings.py

python manage.py runserver 10.120.0.102:8000

使用ip访问

4.uwsgi+djiango的实现

pip install uwsgi

进入djiango项目

cd /opt/jyl

uwsgi –http 10.120.0.102:8080 –file jyl/wsgi.py –static-map=/static=/usr/lib64/python2.7/site-packages/mezzanine/core/static

vim uwsgi.ini

# uwsig使用配置文件启动
[uwsgi]
# 项目目录
chdir=/opt/jyl/
# 指定项目的application
module=jyl.wsgi:application
# 指定sock的文件路径       
socket=/opt/script/uwsgi.sock
# 进程个数       
workers=5
pidfile=/opt/script/uwsgi.pid
# 指定IP端口       
http=10.120.0.102:8080
# 指定静态文件
static-map=/static=/usr/lib64/python2.7/site-packages/mezzanine/core/static
# 启动uwsgi的用户名和用户组
uid=root
gid=root
# 启用主进程
master=true
# 自动移除unix Socket和pid文件当服务停止的时候
vacuum=true
# 序列化接受的内容,如果可能的话
thunder-lock=true
# 启用线程
enable-threads=true
# 设置自中断时间
harakiri=30
# 设置缓冲
post-buffering=4096
# 设置日志目录
daemonize=/opt/script/uwsgi.log

启动项目

uwsgi –ini uwsgi.ini

wancheng

本文来源 互联网收集,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源,如您发现有涉嫌抄袭侵权的内容,请联系本站核实处理。

© 版权声明

相关文章