需要用到bandersnatch工具能与python包同步
1.1 python2.7
pip install bandersnatch==1.11
1.2如果是python3
pip install bandersnatch
生成配置文件
执行:bandersnatch mirror
更改配置:vim /etc/bandersnatch.conf
[mirror]
; The directory where the mirror data will be stored.
directory = /media/ubuntu/0B2E193B0B2E193B/python36env/srv/pypi
*;文件存储路径*
; Save JSON metadata into the web tree:
; URL/pypi/PKG_NAME/json (Symlink) -> URL/json/PKG_NAME
json = false
; The PyPI server which will be mirrored.
; master = https://test.python.org
; scheme for PyPI server MUST be https
master = https://pypi.org
同步python源,执行:
bandersnatch -c /etc/bandersnatch.conf mirror
安装 nginx
apt-get install nginx
配置nginx服务器
在 /etc/nginx/sites-available/default/nginx.conf
启动nginx服务器
/etc/init.d/nginx start
打开网页查看是否正常http://127.0.0.1/simple/
更改服务器配置pip的地址
cat ~/.pip/pip.conf
[global]
trusted-host=172.28.88.102
index-url=http://172.28.88.102/simple