beego项目部署--使用supervisor和nginx
2017-03-20 00:00
477 查看
用一段时间基于beego开发了一个admin系统,等到部署的时候遇到了一堆问题,用了整整一天才处理好,现在整理下来,分享给大家,希望对大家有所帮助吧。
系统环境:centos 7.2 python:2.7.5
nginx安装
建议直接使用 yum install nginx安装,其他方式安装遇到了很多问题,所以推荐使用这个方式安装。然后编辑nginx 的配置文件:
vim /etc/nginx/nginx.conf 文件,添加如下代码:
然后在/etc/nginx/conf.d/目录下创建beepkg.conf文件,添加如下代码:
supervisor安装
同样,推荐使用 yum -y install supervisor安装,使用源码安装或者easy_install安装,使用systemctl restart supervisord 会报错,提示没有对应的目录。通过这种方式安装后,会在/etc/下自动创建 supervisord.conf文件和supervisord.d目录。修改supervisord.conf文件,添加如下代码
然后在 /etc/supervisord.d/目录下创建项目的配置文件 vim beepkg.conf,添加如下代码:
首次启动 supervisord,然后使用supervisorctl start beepkg,如果没有问题,使用systemctl restart supervisord,
再使用systemclt restart nginx,先后顺序不能颠倒
系统环境:centos 7.2 python:2.7.5
nginx安装
建议直接使用 yum install nginx安装,其他方式安装遇到了很多问题,所以推荐使用这个方式安装。然后编辑nginx 的配置文件:
vim /etc/nginx/nginx.conf 文件,添加如下代码:
include /etc/nginx/conf.d/*.conf;
然后在/etc/nginx/conf.d/目录下创建beepkg.conf文件,添加如下代码:
server { listen 80; server_name .b.com; #项目解析的域名 charset utf-8; access_log /home/b.com.access.log main; #输出的日志的位置 location /(css|js|fonts|img)/ { access_log off; expires 1d; root "/path/to/app_b/static"; #项目静态资源的位置 try_files $uri @backend; } location / { try_files /_not_exists_ @backend; } location @backend { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:8081; #这里的端口号要和项目conf/app.conf里面指定的端口号一致 } }
supervisor安装
同样,推荐使用 yum -y install supervisor安装,使用源码安装或者easy_install安装,使用systemctl restart supervisord 会报错,提示没有对应的目录。通过这种方式安装后,会在/etc/下自动创建 supervisord.conf文件和supervisord.d目录。修改supervisord.conf文件,添加如下代码
[include] files = /etc/supervisord.d/*.conf
然后在 /etc/supervisord.d/目录下创建项目的配置文件 vim beepkg.conf,添加如下代码:
[program:beepkg] directory = /opt/app/beepkg #项目文件夹 command = /opt/app/beepkg/beepkg #项目可执行文件位置 autostart = true startsecs = 5 user = root redirect_stderr = true stdout_logfile = /var/log/supervisord/beepkg.log #输出日志文件的位置
首次启动 supervisord,然后使用supervisorctl start beepkg,如果没有问题,使用systemctl restart supervisord,
再使用systemclt restart nginx,先后顺序不能颠倒
相关文章推荐
- 阿里云部署Django项目(超详细图文教程) —— Part2. 使用Nginx, Gunicorn, virtualenv, supervisor 部署Django应用
- Python-在CentOS7上使用nginx+uwsgi部署Flask框架开发的Web项目
- flask部署-Ubuntu下使用nginx+uwsgi+supervisor部署flask应用
- 使用NGINX部署Laravel项目详解
- 利用gunicorn、supervisor、nginx 等部署flask项目
- 使用nginx + uwsgi socket的方式来部署Django项目
- 给我一台全新的服务器,使用nginx+gunicorn+supervisor部署django
- 使用Nginx+uwsgi部署Django项目
- 使用uwsgi+nginx部署django项目
- 在MAC使用Nginx+uWSGI部署Flask项目
- Tomcat项目部署+Nginx的简单使用
- 阿里云(ubuntu)下使用nginx、uwsgi部署django项目
- 初探django-使用uwsgi+supervisor+nginx来部署服务
- flask部署-Ubuntu下使用nginx+uwsgi+supervisor部署flask应用
- 部署项目Nginx+Tornado+Supervisor
- 使用idea开发工具,nginx服务部署Extjs6,SpringBoot项目到服务器
- 使用Gunicorn Ngnx Supervisor部署Django项目
- 阿里云 解决为什么不能使用公网IP地址访问部署的nginx项目
- 部署项目Nginx+Tornado+Supervisor
- 基于ubuntu使用nginx+uwsgi部署django,并使用supervisor管理(不坑人)