网站部署第14天
由于旧的服务器过期了。租了新的服务器.发现Fabric2.0已经不支持Python2了。使用旧版Fabric1.x又会出现各种问题,比如加密解密库会无法使用,唯一好的方法是用Fabric3 1.14可以兼容1.x,2.x fabfile文件。下载链接在这 https://pypi.org/project/Fabric3/ **或者直接(注意是python3环境pip3)** ```bash pip3 install Fabric3==1.14.post1 ```
由于旧的服务器过期了。租了新的服务器.发现Fabric2.0已经不支持Python2了。使用旧版Fabric1.x又会出现各种问题,比如加密解密库会无法使用,唯一好的方法是用Fabric3 1.14可以兼容1.x,2.x fabfile文件。下载链接在这 https://pypi.org/project/Fabric3/ **或者直接(注意是python3环境pip3)** ```bash pip3 install Fabric3==1.14.post1 ```
部署文件在我的Github项目可找到:[https://github.com/yemaobumei/mysite](https://github.com/yemaobumei/mysite) 阿里云服务器需配置网络安全组 HTTP 显示为 80/80。 实例作为网站或 Web 应用的服务器。 - 第一步 安装nginx,fabric,virtualenv **注意安装包对应的python版本** ```bash sudo apt-get install nginx sudo service nginx start sudo pip3 install Fabric3==1.14.post1 sudo pip2 install virtualenv ``` 此时输入网站域名或者IP就能看到welcome to nginx!测试页面 - 第二步 运行自动部署文件fabfile.py 在包含fabfile.py文件的目录下,运行 ```bash fab deploy ```
py文件是#encoding=utf-8编码 然后执行时输出错误 print('\u2312') 这是默认输出编码为ascii。 可进入python执行环境下查看 ``` import sys sys.stdout ``` ### 解决办法1: If you get this error when you try to pipe/redirect output of your script UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128) Just export PYTHONIOENCODING in console and then run your code. 修改.profile 添加一行: PYTHONIOENCODING=utf-8 后执行source .profile ###解决办法2: 在py文件开头加入: ``` import sys import
建个文件 ~/.pip/pip.conf, 内容如下 ``` [global] timeout = 6000 index-url = http://pypi.douban.com/simple/ [install] use-mirrors = true mirrors = http://pypi.douban.com/simple/ trusted-host = pypi.douban.com ```