阿里云上部署python服務(wù)器
1.安裝相關(guān)軟件
#更新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相關(guān)庫
sudo pip3 install jinja2 aiomysql aiohttp
2.安裝oh-my-zsh相關(guān)
#安裝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上項目
#創(chuàng)建相關(guān)目錄并切換
pwd
/home/jax/python
git clone git@github.com:RainliFu/awesome-python-webapp.git
cd awesome-python-webapp
#執(zhí)行數(shù)據(jù)庫操作
mysql -u root -p < schema.sql
5.修改文件權(quán)限
#在windowns中開發(fā)可能會出現(xiàn)編碼問題
/usr/bin/env: ‘python3\r’: No such file or directory
#修改文件編碼
sudo apt install dos2unix
unix2dos ./*.py
#文件權(quán)限可能會導(dǎo)致程序無法執(zhí)行
sudo chmod a+x ./*.py
#測試是否能執(zhí)行
./app.py
-
可能出現(xiàn)無法連接數(shù)據(jù)庫問題
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.修改阿里云服務(wù)器域名解析配置
- 添加awesome解析,地址為服務(wù)器地址
- 測試是否搭建成功,在服務(wù)器中輸入 awesome.[網(wǎng)站名].com 或者直接用域名訪問