阿里云上部署python服务器
1.安装相关软件
#更新apt-get
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx supervisor python3 mysql-server git python3-pip
#更新pip
sudo pip3 install --upgrade pip
#安装pytho相关库
sudo pip3 install jinja2 aiomysql aiohttp
2.安装oh-my-zsh相关
#安装zsh
apt-get install zsh
#安装omz
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
#安装powerline
pip install powerline-status
#添加zsh-syntax-highlighting插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- 添加插件
vi ~/.zshrc
#添加插件
plugins=(zsh-syntax-highlighting)
source ~/.zshrc
3.git配置
git config --global user.name "jax"
git config --global user.email "fuliby2loveyou@gmail.com"
ssh-keygen -t rsa -C "fuliby2loveyou@gmail.com"
4.获取github上项目
#创建相关目录并切换
pwd
/home/jax/python
git clone git@github.com:RainliFu/awesome-python-webapp.git
cd awesome-python-webapp
#执行数据库操作
mysql -u root -p < schema.sql
5.修改文件权限
#在windowns中开发可能会出现编码问题
/usr/bin/env: ‘python3\r’: No such file or directory
#修改文件编码
sudo apt install dos2unix
unix2dos ./*.py
#文件权限可能会导致程序无法执行
sudo chmod a+x ./*.py
#测试是否能执行
./app.py
-
可能出现无法连接数据库问题
6.配置Supervisor
cp ./awesome-python-webapp/conf/supervisor/awesome.conf /etc/supervisor/conf.d/
sudo supervisorctl reload
sudo supervisorctl start awesome
sudo supervisorctl status
awesome RUNNING pid 1401, uptime 5:01:34
7.配置Nginx
cp ./awesome-python-webapp/conf/nginx/awesome /etc/nginx/sites-available/
cd /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/awesome
sudo /etc/init.d/nginx reload
8.修改阿里云服务器域名解析配置
- 添加awesome解析,地址为服务器地址
- 测试是否搭建成功,在服务器中输入 awesome.[网站名].com 或者直接用域名访问