一、Mac环境用Royal TSX连接阿里云
Royal TSX,Mac上强力的远程连接管理神器
直接去官网下载即可:www.royalapps.com/ts/win/down…
Royal TSX -> Plugins
Installed Plugins
下为已安装的插件
点击 Avaiable Plugins
浏览可用插件
安装 Terminal
和 File Transfer
登录阿里云,点【实例】查看公网 ip
在Royal TSX连接阿里云
二、点击左侧 Credentials
,下拉框中选择 Specify username and password
Username
用户名,一般为 root
Password
服务器密码
输完点击 Apply & Close
应用并退出
双击刚刚创建的 SSH
连接就可以进行连接,可能会出现如下提示,忽略直接输入 yes
后 enter
即可
三、服务器库更新,命令:yum update
四、安装相关的开发库发备编译,命令:
[root@iZwz94gsu2pesu7rp6uh90Z /]# yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
五、安装python,命令:
1、[root@iZwz94gsu2pesu7rp6uh90Z ~]# wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
2、解决python包,命令:tar zxf Python-3.7.5.tgz
3、进入解压文件及安装:
[root@iZwz94gsu2pesu7rp6uh90Z ~]# cd Python-3.7.5
[root@iZwz94gsu2pesu7rp6uh90Z Python-3.7.5]# ./configure
[root@iZwz94gsu2pesu7rp6uh90Z Python-3.7.5]# make 说明:作用是编译
[root@iZwz94gsu2pesu7rp6uh90Z Python-3.7.5]# make install 说明:编译后安装
六、创建python虚拟环境,新建一个终端窗口
1、在var/www/文件下创建mysite_venv,命令:
[root@iZwz94gsu2pesu7rp6uh90Z ~]# cd /
[root@iZwz94gsu2pesu7rp6uh90Z /]# cd var
[root@iZwz94gsu2pesu7rp6uh90Z var]# mkdir www
2、进入www文件:[root@iZwz94gsu2pesu7rp6uh90Z var]# cd www
创建虚拟环境:
[root@iZwz94gsu2pesu7rp6uh90Z www]# python3 -m venv mysite_env
激活虚拟环境:
[root@iZwz94gsu2pesu7rp6uh90Z www]# source mysite_env/bin/activate
安装Flask,命令:
(mysite_env) [root@iZwz94gsu2pesu7rp6uh90Z www]# pip3 install flask
七、安装Flask运行的容器 uwsgi,命令:
(mysite_env) [root@iZwz94gsu2pesu7rp6uh90Z www]# pip3 install uwsgi
八、创建站点文件目录,/var/www/mysite,命令:
(mysite_env) [root@iZwz94gsu2pesu7rp6uh90Z www]# mkdir mysite
九、安装git,通过git上传flask项目文件:
十二、在/etc/nginx/nginx.conf配置全局参数设置
[root@iZwz94gsu2pesu7rp6uh90Z etc]# cd nginx
[root@iZwz94gsu2pesu7rp6uh90Z nginx]# vi nginx.conf
十三、在/etc/nginx/conf.d/default.conf 配制当前站点,命令:
[root@iZwz94gsu2pesu7rp6uh90Z nginx]# cd conf.d
[root@iZwz94gsu2pesu7rp6uh90Z conf.d]# vi default.conf
server {
listen 80;
server_name 172.19.000.00;
charset utf-8;
access_log /var/log/nginx/host.access.log main;
error_log /var/log/nginx/host.access.log warn;
# location / {
# #root /usr/share/nginx/html;
# root /var/www/mysite;
# index index.html index.htm;
# }
location /{
root /var/www/mysite;
index index.html index.htm;
include uwsgi_params;
uwsgi_pass 127.0.0.1:5000;
uwsgi_param UWSGI_PYHOME /var/www/mysite_venv;
uwsgi_param UWSGI_CHDIR /var/www/mysite;
uwsgi_param PYTHONPATH /var/www/mysite;
uwsgi_param UWSGI_MODULE hello;
uwsgi_param UWSGI_CALLABLE app;
}
十四、在配制文件/etc/nginx/conf.d/default.conf 启动Nginx服务器,命令:
[root@iZwz94gsu2pesu7rp6uh90Z nginx]# cd ~
[root@iZwz94gsu2pesu7rp6uh90Z ~]# nginx -t -c /etc/nginx/nginx.conf
[root@iZwz94gsu2pesu7rp6uh90Z ~]# systemctl start nginx.service
十五、以/var/www/mysite/uwsgi.ini 配置文件作为参数启动uwsgi容器
[root@iZwz94gsu2pesu7rp6uh90Z ~]# uwsgi --ini /var/www/mysite/uwsgi.ini