ECS使用及环境配置

来源:互联网 发布:fresh 知乎 编辑:程序博客网 时间:2024/06/06 03:48

1.登录ssh root@ip

2.ubuntu 14.04 LTS 阿里云更新源、官方源和第三方更新源列表


能尽量apt-get就apt-get,不要折腾源码安装

3. python重新安装
apt-get remove python
apt-get install python

4. mycli安装
pip install mycli

5.python 虚拟环境[virtualenv/virtualenvwrapper]设置


6.nginx+uwsgi配置

向nginx.conf加入如下
server {        listen       80;        server_name  47.93.124.181;        access_log /root/letfly/firstsite/logs/access.log;        error_log /root/letfly/firstsite/logs/error.log;        location / {                include /etc/nginx/uwsgi_params;                uwsgi_pass  127.0.0.1:9090;        }    }
关闭nginx
nginx -s stop
重链接配置文件
nginx -c /etc/nginx/nginx.conf
重启
nginx -s reload

UWSGI配置
apt-get install python-devpip install uwsgi
uwsgi9090.ini如下
[uwsgi]vhost = falseplugins = pythonsocket = 127.0.0.1:9090master = trueenable-threads = trueworkers = 1wsgi-file = /root/letfly/firstsite/firstsite/wsgi.pychdir = /root/letfly/firstsite
运行
uwsgi --ini uwsgi9090.ini&


7.ubuntu安装vim8.0

sudo add-apt-repository ppa:jonathonf/vim

sudo apt-get update && sudo apt-get upgrade
It these commands don't work above.

You have to use

apt-get -u dist-upgrade

Enforce the package update the last version, and auto process the dependent package issue.

If you also have python error

requires Vim compiled with Python (2.6+ or 3.3+) support

You can use

sudo apt-get install vim-nox

The vim will support the python with newest version

8.语系设置

When I run perl, I get the warning:

perl: warning: Setting locale failed.perl: warning: Please check that your locale settings:    LANGUAGE = (unset),    LC_ALL = (unset),    LANG = "en_US.UTF-8"are supported and installed on your system.perl: warning: Falling back to the standard locale ("C").
export LC_CTYPE=en_US.UTF-8export LC_ALL=en_US.UTF-8
加入到~/.bashrc

9.登录微信平台
views.py
#-*- coding:utf-8 -*-import sysreload(sys)sys.setdefaultencoding('utf8')from django.http.response import HttpResponse, HttpResponseBadRequestfrom django.views.decorators.csrf import csrf_exemptfrom wechat_sdk import WechatConffrom wechat_sdk import WechatBasicfrom wechat_sdk.exceptions import ParseErrorfrom wechat_sdk.messages import (TextMessage, VoiceMessage, ImageMessage, VideoMessage, LinkMessage, LocationMessage, EventMessage, ShortVideoMessage)conf = WechatConf(   token='YOUR_TOKEN_HERE',   appid='YOUR_APPID',   appsecret='YOUR_APPSECRET',   encrypt_mode='YOUR_MODE',   encoding_aes_key='YOUR_AES_KEY')@csrf_exemptdef wechat_home(request):   signature = request.GET.get('signature')   timestamp = request.GET.get('timestamp')   nonce = request.GET.get('nonce')   wechat_instance = WechatBasic(conf=conf)   if not wechat_instance.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):       return HttpResponseBadRequest('Verify Failed')   else:       if request.method == 'GET':           response = request.GET.get('echostr', 'error')       else:           try:               wechat_instance.parse_data(request.body)                   message = wechat_instance.get_message()                           if isinstance(message, TextMessage):                               reply_text = 'text'               elif isinstance(message, VoiceMessage):                               reply_text = 'voice'               elif isinstance(message, ImageMessage):                               reply_text = 'image'               elif isinstance(message, LinkMessage):                               reply_text = 'link'               elif isinstance(message, LocationMessage):                           reply_text = 'location'               elif isinstance(message, VideoMessage):                               reply_text = 'video'               elif isinstance(message, ShortVideoMessage):                       reply_text = 'shortvideo'               else:                   reply_text = 'other'               response = wechat_instance.response_text(content=reply_text)           except ParseError:                   return HttpResponseBadRequest('Invalid XML Data')       return HttpResponse(response, content_type="application/xml")
urls.py
urlpatterns = [   url(r'^wechat/', views.wechat_home),]

微信后台配置



自定义菜单:自定义链接:需要公众号认证

订阅号无法认证

只有服务号和企业号可以认证。

10. docker的使用



0 0
原创粉丝点击