Django部署 uwsgi+nginx

mysite 位置 :/usr/local下(/etc下也有)

uwsgi位置 /usr/local/python3/bin/uwsgi

socket:8001

http:9000

虚拟环境位置: /root/blogenv

yum install nginx遇到报错,发现是由于升级了python后导致,通过vi打开对应报错的文件,将开头的python改为python2.7即可

yum install nginx 报错----cannot allocate memeory 内存不够用,通过free -m释放内存

若free不起作用

通过一下方法添加虚拟内存


fallocate -l 512M /swapfile

chmod 600 /swapfile

mkswap /swapfile

swapon /swapfile

移除swap file


swapoff -a

rm -f /swapfile

安装必要的包


sudo yum install epel-release

sudo yum install python-devel

将SELinux设置为宽容模式


sudosetenforce 0

关闭防火墙


sudo systemctl stop firewalld

在安装完uwsgi后,发现无法启动,输入uwsgi后,显示command not found

后来发现可能使环境变量的问题

修改环境变量

cd /root

ls -al .bash_profile(.bash_profile为隐藏文件)

vi .bash_profile

添加以下内容:

source .bash_profile

如何启动项目

首先启动uwsgi

supervisord -c /etc/supervisord.conf
supervisorctl -c /etc/supervisord.conf start mysite

然后启动nginx

service nginx start

关闭防火墙

sudo systemctl stop firewalld`

这样就启动成功啦

后续测试中需要添加日志文件,设置日志文件位置,在nginx.conf中添加

access_log /var/log/access.log
error_log /var/log/error.log
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容