centos

使用 yum 管理包

  1. yum update
  2. sudo yum install yum-utils
  3. yum install python3

Ubuntu 16.04

一条命令安装python3.7
https://blog.csdn.net/jaket5219999/article/details/80894517(没有用了)
https://blog.csdn.net/qq_35933777/article/details/84325856(编译十几分钟 ./configure 生成编译文件)
pip3的问题 /usr/bin/文件夹下的pip3文件
将原来的:
from pip import main
if name == ‘main‘:
sys.exit(main())

改成:
from pip import main
if name == ‘main‘:
sys.exit(main._main())
https://blog.csdn.net/tintinetmilou/article/details/80091630
mysql
https://blog.csdn.net/weixx3/article/details/80782479

  1. apt-get update
  2. apt-get install screen
  3. apt-get install git
  4. apt install python3-pip
  5. sudo apt-get remove python3
  6. apt-get install python3
  7. sudo apt-get install python3-pip
  8. apt-get install mysql-server

创建数据库
进入数据库 基础教程https://www.jianshu.com/p/3e399c76b132

  1. mysql -uroot -p
  2. show databases;// 查看当前数据库
  3. create DATABASE RUNOOB; //创建一个名为 RUNOOB的数据库

跑python flask项目

  1. git clone..
  2. cd ...
  3. pip3 install -r requirements.txt

跑80端口服务:python3 main.py runserver -h 0.0.0.0 -p 80

常用命令

ps命令查找与进程相关的PID号:
ps a 显示现行终端机下的所有程序,包括其他用户的程序。
kill 杀死线程

screen -S name #创建一个窗口,并且为这个窗口命名
screen -ls #可以查看已创建的所有窗口

apt autoremove

没有MYSQLdb

  1. sudo apt-get install libmysqlclient-dev
  2. pip3 install mysqlclient
  3. apt-get install mysql-server

raise EnvironmentError(“%s not found” % (_mysql_config_path,)) OSError: mysql_config not found
修改 mysql 中文编码问题
show variables like ‘%char%’;
set character_set_server=utf8;
set character_set_database=utf8;
show variables like ‘%char%’;
中文编码问题
https://blog.csdn.net/luoweifu/article/details/8832492
create DATABASE yqy CHARACTER SET ‘utf8’ COLLATE ‘utf8_general_ci’;

react 项目 build 与上传

sudo scp -i ~/yqy.pem -r ./build/* root@59.110.237.244:/var/www/html

nginx

CentOS 7 安装 Nginx

  1. $ sudo yum -y install nginx # 安装 nginx
  2. $ sudo yum remove nginx # 卸载 nginx

检测两个目录下的东西
include /etc/nginx/conf.d/.conf;
include /etc/nginx/sites-enabled/
;

  1. server {
  2. # server_name abc.test.com;
  3. listen 80;
  4. location / {
  5. root /var/www/html;
  6. index index.html;
  7. try_files $uri $uri/ /index.html;
  8. }
  9. location ^~ /api {
  10. proxy_pass http://127.0.0.1:8088/api;
  11. }
  12. }

Nginx 测试
nginx -t
nginx -s reload 重启

基础配置
https://juejin.cn/post/6844903575210967048#heading-15

80 端口问题
https://serverfault.com/questions/842492/nginx-duplicate-listen-options-for-80-error/842515
https://stackoverflow.com/questions/14972792/nginx-nginx-emerg-bind-to-80-failed-98-address-already-in-use

https 证书配置

ubuntu开放指定端口

https://www.jianshu.com/p/2ec5d16db02b