- 安装python3
CentOS7系统自带的Python版本是Python2.7,如需使用Python3.6,需要自行安装Python3.6。
CentOS7安装Python3.6有两种方式:
- 使用Yum源安装Python3.6
- 使用Python3.6源文件安装
推荐使用CentOS7 Yum源安装Python3.6。
CentOS7使用Yum源安装Python3.6(已失效
)
IUS软件源中包含了Python3.6,可以使用IUS软件源安装Python3.6,查看如何安装使用IUS软件源
1)安装IUS软件源
#安装EPEL依赖
yum install epel-release -y
#安装IUS软件源
yum install https://centos7.iuscommunity.org/ius-release.rpm -y
2)安装Python3.6
yum install python36u -y
安装Python3完成后的shell命令为python3.6,为了使用方便,创建一个到python3的符号链接
ln -s /bin/python3.6 /bin/python3
3)安装pip3
安装完成python36u并没有安装pip,安装pip
yum install python36u-pip -y
安装pip完成后的shell命令为pip3.6,为了使用方便,创建一个到pip3的符号链接
ln -s /bin/pip3.6 /bin/pip3
CentOS7使用Yum源安装Python3.6
1)安装IUS软件源
#安装EPEL依赖
yum install epel-release -y
#安装IUS软件源
yum install https://mirrors.tuna.tsinghua.edu.cn/ius/ius-release-el7.rpm -y
2)安装Python3.6
yum search python36
# 找到需要安装的python包
yum install xxxx -y
## CentOS7使用源文件安装Python3.6
1)在安装Python3.6之前,先安装Python3.6需要的依赖:
sudo yum -y groupinstall development
sudo yum -y install zlib-devel
2)运行如下命令安装Python3.6
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xJf Python-3.6.0.tar.xz
cd Python-3.6.0
sudo ./configure
sudo make
sudo make install
安装完成后,Python安装在了`/usr/local`文件夹中,可运行文件`/usr/local/bin`,库文件`/usr/local/lib`
###- nginx配置文件
```vim /etc/nginx/conf.d/py.conf ```
server {
listen 80;
server_name 47.102.129.254;
client_max_body_size 100M;
location /static {
alias /root/code/FULL_BBS/static;
}
location /media {
alias /root/code/FULL_BBS/media/;
}
location / {
index index.html;
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
uwsgi_param UWSGI_SCRIPT FULL_BBS.wsgi;
uwsgi_param UWSGI_CHDIR /root/code/FULL_BBS;
}
}
###- uwsgi配置文件
```pip3 install uwsgi安装失败问题的解决```
- python --version 命令查看python版本
- yum search python3
- yum install python36u-devel.x86_64 -y
4.或者yum install gcc -y
```vim 项目最外层目录/uwsgi.ini```
[uwsgi]
socket = 127.0.0.1:9090
master = true
workers = 2
reload-mercy = 10
vacuum = true
max-requests = 1000
limit-as = 512
buffer-size = 30000
flask项目配置
[uwsgi]
socket = 127.0.0.1:9090
processes = 4
threads = 2
master = true
pythonpath = /var/www/web/movie
module = manage
callable = app
memory-report = true
python3 manage.py db init
python3 manage.py db migrate
python3 manage.py db upgrade