当前位置: 首页 > news >正文

做网站建设哪家公司好今日头条极速版官网

做网站建设哪家公司好,今日头条极速版官网,广州seo优化费用,建设厅网站装修合同模板查看原文:http://www.sijitao.net/2054.html 因为django 1.8至少需要python 2.7以上的版本,所以在部署django之前还需要确保python版本是否满足要求。上一篇文章介绍了如何在centos 6.5中单独安装python 2.7 ,如果你的python已经是2.7可以略过…

查看原文:http://www.sijitao.net/2054.html
因为django 1.8至少需要python 2.7以上的版本,所以在部署django之前还需要确保python版本是否满足要求。上一篇文章介绍了如何在centos 6.5中单独安装python 2.7 ,如果你的python已经是2.7可以略过此步骤。

安装uwsgi

(ch)[py27@localhost ~]$ pip install uwsgi
Collecting uwsgiDownloading uwsgi-2.0.11.1.tar.gz (782kB)100% |████████████████████████████████| 782kB 144kB/s 
Building wheels for collected packages: uwsgiRunning setup.py bdist_wheel for uwsgiStored in directory: /home/py27/.cache/pip/wheels/65/00/6e/34678eb0a21a697c1646c71ccfabd1cb3c310c20797c60ad01
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.11.1

安装直接使用pip ,迁移是用的python2.7版本的pip。安装完成之后简单测试下uwsgi。

新建一个test.py文件:

def application(env, start_response):start_response('200 OK', [('Content-Type','text/html')])return "Hello World"

输入“uwsgi --http :8001 --wsgi-file test.py”启动uwsgi,可以看到类似如下的内容。

(ch)[py27@localhost ~]$ uwsgi --http :8001 --wsgi-file test.py
*** Starting uWSGI 2.0.11.1 (64bit) on [Wed Sep 23 16:53:25 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-16) on 23 September 2015 16:41:18
os: Linux-2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013
nodename: localhost.localdomain
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/py27
detected binary path: /home/py27/ch/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8001 fd 4
spawned uWSGI http 1 (pid: 15856)
uwsgi socket 0 bound to TCP address 127.0.0.1:38968 (port auto-assigned) fd 3
Python version: 2.7.10 (default, Sep 23 2015, 16:33:09) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x203ccb0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72768 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x203ccb0 pid: 15855 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 15855, cores: 1)

在浏览器打开ip:8001这个地址应该可以看到“hello world”页面。

安装django

使用pip安装django最简单。

(ch)[py27@localhost ~]$ pip install Django
Collecting DjangoDownloading Django-1.8.4-py2.py3-none-any.whl (6.2MB)100% |████████████████████████████████| 6.2MB 61kB/s 
Installing collected packages: Django
Successfully installed Django-1.8.4

创建一个django项目测试。

(ch)[py27@localhost ~]$ django-admin.py startproject mysite
(ch)[py27@localhost ~]$ ll
total 12
drwxrwxr-x. 5 py27 py27 4096 Sep 23 16:41 ch
drwxrwxr-x. 3 py27 py27 4096 Sep 23 17:00 mysite
-rw-rw-r--. 1 py27 py27 118 Sep 23 16:49 test.py
(ch)[py27@localhost ~]$ cd mysite/
(ch)[py27@localhost mysite]$ python manage.py runserver 0.0.0.0:8001
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
September 23, 2015 - 09:00:44
Django version 1.8.4, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8001/
Quit the server with CONTROL-C.
[23/Sep/2015 09:00:56] "GET / HTTP/1.1" 200 1767
[23/Sep/2015 09:00:56] "GET /favicon.ico HTTP/1.1" 404 1942

浏览器看到django页面说明django安装成功。

uwsgi和django整合

django的runserver只在测试环境使用,正式环境不推荐使用这种方式。所以需要使用uwsgi调用django程序。django 1.4以上的版本在项目创建的时候会自动生产wsgi模块。

uwsgi支持很多种的配置方式,这里博主使用ini文件。

[uwsgi]
project = mysite
base = /home/py27
chdir = %(base)/%(project)
module = %(project).wsgi:application
;socket = 127.0.0.1:8001
;socket = /home/pyuser/var/%(project).sock
;chmod-socket = 664
http = 0.0.0.0:8001
master = true
processes = 3
vacuum = true
pidfile = /home/py27/uwsgi8001.pid
daemonize = /home/py27/uwsgi8001.log

连接时有socket和http两种方式,socket一般是提供给第三方调用,而http可以接受浏览器的http请求。上面配置文件是为了测试,接下来如果使用nginx时可以使用socket+端口或者socket+sock两种方式。

启动

(ch)[py27@localhost ~]$ uwsgi --ini mysite.ini 
[uWSGI] getting INI configuration from mysite.ini
(ch)[py27@localhost ~]$ tailf uwsgi8001.log 
your mercy for graceful operations on workers is 60 seconds
mapped 291072 bytes (284 KB) for 3 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x14370a0 pid: 16050 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 16050)
spawned uWSGI worker 1 (pid: 16053, cores: 1)
spawned uWSGI worker 2 (pid: 16054, cores: 1)
spawned uWSGI worker 3 (pid: 16055, cores: 1)
spawned uWSGI http 1 (pid: 16056)
[pid: 16055|app: 0|req: 1/1] 192.168.140.1 () {36 vars in 619 bytes} [Wed Sep 23 09:13:44 2015] GET / => generated 1767 bytes in 13 msecs (HTTP/1.1 200) 2 headers in 73 bytes (1 switches on core 0)

出现这个界面且浏览器打开正常说明django和uwsgi整合成功。有关uwsgi的详细配置参考官方文档。

配置nginx

安装完nginx后增加类似如下配置文件,重新加载nginx即可。

server{listen 80;server_name manage.hostunion.net;
location ~ ^/static/admin(/|$) {root /home/py27/ch/lib/python2.7/site-packages/django/contrib/admin ;}
location ~ ^/static(/|$) {root /home/py27/mysite;}
location / {include uwsgi_params;#uwsgi_pass 127.0.0.1:8001;uwsgi_pass unix:/home/py27/var/mysite.sock;}
access_log /home/wwwlogs/manage.hostunion.net.log access;}

不出意外,django项目的部署就完成了。

参考连接:

http://stackoverflow.com/questions/15878176/uwsgi-invalid-request-block-size

http://www.sijitao.net/2050.html

http://www.lbrq.cn/news/2657215.html

相关文章:

  • 遨翔网站建设程序员培训班要多少钱
  • 武汉做网站建设抖音视频排名优化
  • 华企网站建设推广优化北京网站推广服务
  • 国内可以做网页的网站电商运营培训大概多少学费
  • 外贸网站建设系统游戏推广赚佣金平台
  • 连云港专业网站优化2022年最新新闻播报稿件
  • 国产做性直播视频网站友情链接网站免费
  • 营销网站建设推广成都网站快速排名优化
  • 东莞公司建设网站销售管理系统
  • 百度网站标题营销方式和渠道
  • 怎么建设素材网站免费网站提交入口
  • 洛阳企业网站建设视频号的链接在哪
  • 云南网站建设百度官方百度竞价返点一般多少
  • 贵阳网站建设运营免费发布推广信息的平台
  • wordpress 密码爆破宁波 seo排名公司
  • 企业登记网上注册杭州明开seo
  • 肇庆网站建设咨询百度seo排名公司
  • WordPress怎么用dz登录怎么进行seo
  • h5游戏充值折扣平台seo搜索引擎优化推广
  • 如何用代码做分数查询的网站最近的新闻摘抄
  • 360上做网站威海seo公司
  • 留言网站怎么做扫图片识别图片原图
  • 中国企业查询网官网洛阳网站建设优化
  • 国外做免费网站的制作电商网站
  • 圣耀做单网站小程序开发流程详细
  • 如何自己制作简单脚本单页面seo搜索引擎优化
  • 乐清做网站的公司有哪些域名收录查询工具
  • 系统优化有什么用3分钟搞定网站seo优化外链建设
  • 专做美妆的视频网站怎么查询百度收录情况
  • 新手建设网站步骤视频营销
  • 学习观察和行动:机器人操作中任务-觉察的视图规划
  • 十、Linux Shell脚本:流程控制语句
  • 实现两个开发板的串口通讯(基于STC8实现)
  • spring-boot-starter-data-redis 与 org.redisson 区别 联系
  • 复现论文《基于深度强化学习的微能源网能量管理与优化策略研究》
  • RecyclerView 缓存机制