一、安装Nginx
sudo apt-get install nginx
配置文件:
文件位置:/etc/nginx/sites-enabled/
server { listen 80; server_name ios.plar.cn; access_log /var/log/nginx/example_access.log; error_log /var/log/nginx/example_error.log; root /root/seo.plar.cn; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:8080; } }
ubuntu安装Nginx之后的文件结构大致为:
所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下
启动程序文件在/usr/sbin/nginx
日志放在了/var/log/nginx中,分别是access.log和error.log
并已经在/etc/init.d/下创建了启动脚本nginx
默认的虚拟主机的目录设置在了/usr/share/nginx/www
二、安装uWSGI
apt-get install uwsgi apt-get install uwsgi-plugin-python
配置文件:
文件位置:/etc/uwsgi/apps-enabled/
<uwsgi> <plugin>python</plugin> <socket>127.0.0.1:8080</socket> <pythonpath>/root/seo.plar.cn/</pythonpath> <app mountpoint="/"> <script>index</script> </app> <master/> <processes>4</processes> <reload-mercy>8</reload-mercy> <cpu-affinity>1</cpu-affinity> <max-requests>2000</max-requests> <limit-as>512</limit-as> <reload-on-as>256</reload-on-as> <reload-on-rss>192</reload-on-rss> <no-orphans/> <vacuum/> </uwsgi>
script,开始的脚本文件名称
python path,python项目目录
socket,端口
并发4个线程:
- uwsgi -s :9090 -w myapp -p 4
主控制线程+4个线程:
- uwsgi -s :9090 -w myapp -M -p 4
执行超过30秒的client直接放弃:
- uwsgi -s :9090 -w myapp -M -p 4 -t 30
限制内存空间128M:
- uwsgi -s :9090 -w myapp -M -p 4 -t 30 –limit-as 128
服务超过10000个req自动respawn:
- uwsgi -s :9090 -w myapp -M -p 4 -t 30 –limit-as 128 -R 10000
后台运行等:
- uwsgi -s :9090 -w myapp -M -p 4 -t 30 –limit-as 128 -R 10000 -d uwsgi.log
转载随意~:陶醉 » Nginx+uWSGI+bottle