设为首页 收藏本站
查看: 1083|回复: 0

[经验分享] 整合Nginx、uwsgi、webpy运行simple-todo程序-持续更新中

[复制链接]

尚未签到

发表于 2018-11-13 09:47:49 | 显示全部楼层 |阅读模式
  最近对python非常感兴趣,想通过python web实现一些运维自动化,对于这类简单的应用,webpy当然是不二之选,综合参考,选定了Nginx、uwsgi、webpy这套组合,对于python web 程序的9种部署方式,请参考神贴http://lutaf.com/141.htm,系统及相关软件版本详见如下,
  # cat /etc/redhat-release

  
CentOS>  
# uname -a
  
Linux sandy 2.6.18-274.el5 #1 SMP Fri Jul 22 04:43:29 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
  # rpm -qa python
  
python-2.4.3-44.el5
  一、安装pcre、nginx、setuptools、web.py、uwsgi、MySQL、MySQL-python
  


  • #!/bin/sh
  • ## QQ:804586747    WEIBO:http://weibo.com/careersh  


  • mkdir -p /data/www/to
  • cd /tmp/uwsgiwebpy
  • tar zxvf pcre-8.10.tar.gz
  • cd pcre-8.10
  • ./configure
  • make && make install
  • cd ../
  • tar zxvf nginx-0.8.53.tar.gz
  • cd nginx-0.8.53
  • ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --user=www --group=www --with-http_realip_module --with-http_flv_module --with-http_gzip_static_module
  • make && make install
  • cd ../

  • tar zxvf setuptools-0.6c11.tar.gz
  • cd setuptools-0.6c11
  • python setup.py install
  • cd ../
  • tar zxvf web.py-0.37.tar.gz
  • cd web.py-0.37
  • python setup.py install
  • cd ../
  • tar zxvf uwsgi-1.4.9.tar.gz
  • cd uwsgi-1.4.9
  • python uwsgiconfig.py --build
  • python setup.py install

  • cd /tmp/mysql5.5.30
  • rpm -ivh  MySQL-server-5.5.30-1.rhel5.x86_64.rpm MySQL-client-5.5.30-1.rhel5.x86_64.rpm MySQL-devel-5.5.30-1.rhel5.x86_64.rpm MySQL-shared-compat-5.5.30-1.rhel5.x86_64.rpm MySQL-shared-5.5.30-1.rhel5.x86_64.rpm
  • service mysql start
  • cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
  • cd /tmp/uwsgiwebpy
  • tar zxvf MySQL-python-1.2.3.tar.gz
  • cd MySQL-python-1.2.3
  • echo "mysql_config = /usr/bin/mysql_config" >>site.cfg
  • python setup.py build
  • python setup.py install

  • echo "All Over!!
  至此软件安装完毕,拷贝simple-todo应用至/data/www/to目录下
  simple-todo源码已添加到附件,simple-todo原帖请见http://simple-is-better.com/news/309
  二、建库,导入sql
  [root@sandy ~]# mysql -u root -p
  
Enter password:
  
mysql> create database todo;
  导入\simple-todo\static\sql中的todo.sql
  #mysql -u root -p todo < todo.sql
  三、更改应用启动文件
  更改simple-todo目录下的code.py文件,修改其中的“app.run()”为application = app.wsgifunc()
  并注释掉if __name__ == &quot;__main__&quot;:
  四、配置nginx
  


  • server {
  •         listen       80;
  •         server_name  localhost;

  •         #charset koi8-r;

  •         #access_log  logs/host.access.log  main;
  •        location / {
  •         include uwsgi_params;
  •         uwsgi_pass 127.0.0.1:9000;
  •         autoindex on;
  •     #    root /data/www/to;
  •         }
  •     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
  •          root /data/www/to;
  • }
  •     location ~ .*\.(js|css)?$ {
  •          root /data/www/to;
  • }
  

  五、启动
  


  • 启动nginx
  • #/usr/local/nginx/sbin/nginx
  • 启动uwsgi
  • [root@sandy ~]# uwsgi  -s 127.0.0.1:9000 -w  code 如果以下语句,则表明已启动成功
  • WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xd2d2500 pid: 19752 (default app)
  

  六、测试
  通过浏览器访问IP如下:

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-634428-1-1.html 上篇帖子: 搭建web服务器(jdk+nginx+resin整合) 下篇帖子: Cenots下nginx+uwsgi+web.py环境部署总结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表