首页 > 系统相关 >uwsgi安装及配置搭档nginx

uwsgi安装及配置搭档nginx

时间:2022-11-11 23:34:27浏览次数:33  
标签:do NAME 搭档 start -- echo nginx uwsgi


环境比较奇葩 

​​Centos5.6​​  + python 2.7.8

于是有很多问题。

1.安装uwsgi

不能采用网上的方式:

easy_install   -->  pip  -->  安装uwcgi 

提示错误:warning: implicit declaration of function ‘accept4’

各种尝试都有错误

经过查询 系统库不支持:在accept4()用 linux 系统调用是可以启动 2.6.28 ;支持中 glibc 的版本开始 2.10.

参考:http://www.helplib.net/s/linux.die/65_318/man-2-accept4.shtml


只能降低版本,源码安装经测试:

wget http://projects.unbit.it/downloads/uwsgi-1.3.tar.gz
tar xzvf uwsgi-1.3.tar.gz
cd uwsgi-1.3
make
make install 

可以。

妈妈的热泪盈眶啊

2.安装nginx没什么难度掠过

3.配置nginx的uwsgi

server {
listen 80;
server_name uwsgi.xx.com;
index index.html index.htm index.php;
root /opt/wf_stats;
access_log logs/stats.access.log main;
error_log logs/stats.error.log;

location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090; #必须和uwsgi中的设置一致
index index.html index.htm;
client_max_body_size 55m;
}
}

这个是vhost 的配置,其他方式的类似


4.wgsgi的配置

[uwsgi]
socket = 127.0.0.1:9090
;主进程
master = true
;多站模式
vhost = true
;多站模式时不设置入口模块和文件
no-stie = true
;子进程数
workers = 2
reload-mercy = 10
;退出、重启时清理文件
vacuum = true
max-requests = 1000
limit-as = 512
buffer-sizi = 30000
wsgi-file = [path]/testUwsgi.py
;pid文件,用于下面的脚本启动、停止该进程
pidfile = /opt/modules/uwsgi/logs/uwsgi9090.pid
daemonize = /opt/modules/uwsgi/logs/uwsgi9090.log


5.wgsig测试

python测试文件:


def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World"
</pre><pre name="code" class="html" style="font-weight: bold;">保存为testUwsgi.py

不需要nginx的测试

uwsgi --http :9090  --wsgi-file wsgi.py --master --processes 4 --threads 2 


6.wgsig的启动shell


#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for uwsgi webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add uwsgi'

### BEGIN INIT INFO
# Provides: uwsgi
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the uwsgi web server
# Description: starts uwsgi using start-stop-daemon
### END INIT INFO

# Author: licess
# website: http://lnmp.org

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="uwsgi daemon"
NAME=uwsgi9090
DAEMON=/usr/local/bin/uwsgi
CONFIGFILE=/etc/$NAME.ini
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
$DAEMON $CONFIGFILE || echo -n "uwsgi already running"
}

do_stop() {
$DAEMON --stop $PIDFILE || echo -n "uwsgi not running"
rm -f $PIDFILE
echo "$DAEMON STOPED."
}

do_reload() {
$DAEMON --reload $PIDFILE || echo -n "uwsgi can't reload"
}

do_status() {
ps aux|grep $DAEMON
}

case "$1" in
status)
echo -en "Status $NAME: \n"
do_status
;;
start)
echo -en "Starting $NAME: \n"
do_start
;;
stop)
echo -en "Stopping $NAME: \n"
do_stop
;;
reload|graceful)
echo -en "Reloading $NAME: \n"
do_reload
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload}" >&2
exit 3
;;
esac

exit 0



uwsgi9090 start 启动uwsgi






可以了  启动nginx 和  uwsgi 浏览器中访问 

uwsgi.xx.com




参考:


对比:http://developer.51cto.com/art/201010/229615.htm








标签:do,NAME,搭档,start,--,echo,nginx,uwsgi
From: https://blog.51cto.com/u_2776699/5845583

相关文章

  • nginx高并发优化之静态文件缓存配置
    一、配置http{open_file_cachemax=65535inactive=20s;open_file_cache_valid30s;open_file_cache_min_uses4;open_file_cache_errorson;}二、说明NGINX虽然已......
  • 1.nginx学习
    我们平时访问的网络网站就是WEB网络服务,允许用户通过浏览器访问互联网中的各种资源服务WEB服务器会通过HTTP或者HTTPS的方式将请求内容传递给客户端  目前常见的WEB......
  • Nginx重写功能
    一、常用的Nginx正则表达式字符涵义以及示例^匹配输入字符串的起始位置$匹配输入字符串的结束位置*匹配前面的字符零次或多次;如“ol*”能匹配“o”及“o......
  • 性能瓶颈分析—Nginx
    性能瓶颈分析—Nginxnginx基本运行原理用户连接master中开的端口,控制connectcontrol连接worker有多少worker就有多少线程worker连接其他服务器nginx配置参数介绍......
  • Windows和Centos7安装uWSGI
    uWSGI是一个Web服务器,它实现了WSGI协议、uwsgi、http等协议。Nginx中HttpUwsgiModule的作用是与uWSGI服务器进行交换。WSGI是一种Web服务器网关接口。它是一个Web服务器(如n......
  • Nginx优化与防盗链
    一、Nginx优化1、隐藏版本号可以使用Fiddler工具抓取数据包,查看Nginx版本,也可以在CentOS中使用命令curl-Ihttp://192.168.246.177显示响应报文首部信息。curl-I......
  • Nginx网站服务配置
    概述一款高性能、轻量级Web服务软件稳定性高系统资源消耗低对HTTP并发连接的处理能力高单台物理服务器可支持30000~50000个并发请求Nginx和Apache的差异轻量级,ngi......
  • nginx优化与防盗链
    隐藏版本号显示版本号使用curl命令[root@localhost~]#curl-Ihttp://192.168.136.40    隐藏版本号一:修改配置文件1.vim/usr/local/nginx/conf/nginx......
  • Nginx 优化与防盗链
    一、隐藏版本号1、隐藏版本号的操作步骤可以使用Fiddler工具抓取数据包,查看Nginx版本,也可以在CentOS中使用命令 curl-Ihttp://192.168.160.60显示响应报文首部......
  • django+uwsgi+nginx+docker 部署出现的问题汇总
    前言部署环境,虚拟机ubuntu20.04,docker+uwsig+django+nginx部署,django+uwsgi一个容器,nginx一个容器。测试出现问题总结:1.postmane发送请求时,postman显示Error:socket......