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-dev
pip install uwsgi
uwsgi9090.ini如下
[uwsgi]
vhost = false
plugins = python
socket = 127.0.0.1:9090
master = true
enable-threads = true
workers = 1
wsgi-file = /root/letfly/firstsite/firstsite/wsgi.py
chdir = /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-8
export LC_ALL=en_US.UTF-8
加入到~/.bashrc
9.登录微信平台
views.py
#-*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from django.http.response import HttpResponse, HttpResponseBadRequest
from django.views.decorators.csrf import csrf_exempt
from wechat_sdk import WechatConf
from wechat_sdk import WechatBasic
from wechat_sdk.exceptions import ParseError
from 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_exempt
def 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的使用
安装docker&ubuntu
下载https://mirrors.aliyun.com/docker-toolbox/mac/docker-for-mac/stable/安装,
然后点docker图标启动,
安装ubuntu镜像
docker pull ubuntu:14.04
改名字
docker tag image_id ubuntu:latest
删除原有镜像
docker rmi ubuntu:14.04
进入ubuntu镜像
docker run -ti ubuntu:latest /bin/bash
不同窗口进入同一session_id的image
docker exec -it session_id /bin/bash
保存docker
docker commit session_id ubuntu:latest
拷贝
docker cp session_id:/XXX/XXX /