环境:
1、Ubuntu 服务器
2、python3.7.5
安装
1、python3.7.5
安装的话还是比较简单,流程大致是
./configure ->make && make install ->创建python软连接 pip软连接
安装起来倒是简单,安装完成运行才会遇到各种各样的问题,缺少插件啥的。
1.1、下载包 python3.7.5
1.2、问题
a、No module named '_ctypes'
sudo apt-get install libffi-dev 需不需要重新安装看ok不
b、No module named _ssl
安装之前修改下安装包里面的modules里面的setup.dist文件的内容
ex: /usr/web/tornadoTest/package/Python-3.7.5/Modules/Setup.dist 我的安装目录
大约 206行左右,去掉注释即可
然后再重新安装,等pip这些可以用起来了在开始下一步。
2、安装所需的package
需要的包有mysqldb tornado torndb,看你用的是pymysql还是mysqldb
2.1 普通安装 pip install
2.2 mysqldb 安装
安装mysqldb 之前需要配置mysql_config
sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
然后安装。
3、启动错误
3.1 torndb的错误
if MySQLdb is not None:
# Fix the access conversions to properly recognize unicode/binary
FIELD_TYPE = MySQLdb.constants.FIELD_TYPE
FLAG = MySQLdb.constants.FLAG
CONVERSIONS = copy.copy(MySQLdb.converters.conversions)
field_types = [FIELD_TYPE.BLOB, FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]
if 'VARCHAR' in vars(FIELD_TYPE):
field_types.append(FIELD_TYPE.VARCHAR)
#for field_type in field_types:
# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
注释掉这个
3.2 然后启动成功查询数据时可能还会原道这种错误。
https://www.cnblogs.com/simplezhuo/p/9811369.html
4、nginx 配置
4.1、tornado服务可以运行
python server.py --port 8888
nohup python server.py 登出也不会停止。
4.2、配置
default.conf
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
upstream tornados{
server 127.0.0.1:8888;
}
proxy_next_upstream error;
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!#
# include snippets/snakeoil.conf;
# Add index.php to the list ifyou are using PHP
index index.html index.htm index.nginx-debian.html;
server_name111.231.201.164;
location/cnc/1/{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/cnc/2/{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/cnc/3{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/cnc/4{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/cnc/5{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/cnc/6{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/cnc/7{
alias/usr/web/cnc/;
index index.html index.htm;
}
location/api/{
allow111.231.201.164;
proxy_pass_header Server;
proxy_set_header Host $http_host;