一、添加源
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache fast
二、安装python3
yum -y install python3
yum -y install python3-devel sqlite-devel openssl-devel zlib-devel
yum -y install gcc
yum -y install zip
yum -y install unzip
三、下载pip2pi
pip3 install pip2pi -i https://mirrors.aliyun.com/pypi/simple/
四、批量下载软件包
rm -rf pypi
pip3 install wheel -i https://mirrors.aliyun.com/pypi/simple/
pip3 wheel --timeout 120 --wheel-dir pypi/ --find-links pypi/ --trusted-host mirrors.aliyun.
com -r requirements.txt
# pip3 download -d pypi/ -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
五、建立索引
cd
rm -rf pypi/simple
/usr/local/bin/dir2pi pypi
六、打包
cd
rm -rf pypi.zip
zip -r pypi.zip pypi/
# 下面打包方式不行,因为会把simple里面的文件给优化掉,安装就会报错
# rm -rf pypi.tar.gz
# tar zcvf pypi.tar.gz pypi/
七、关闭防火墙与selinux
systemctl stop firewalld
systemctl disable firewalld
sed -i -e 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
八、Nginx配置
yum install -y nginx
sed -i -e 's/80 default_server/88 default_server/g' /etc/nginx/nginx.conf
sed -i -e 's/user nginx;/user root;/g' /etc/nginx/nginx.conf
cat > /etc/nginx/conf.d/pypi_ngnix.conf << EOF
server {
listen 10080;
server_name pypi;
root /opt/pypi;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location /{
}
}
EOF
systemctl restart nginx
systemctl status nginx
systemctl enable nginx
九、web访问pip源
http://103.45.102.36:10080/simple/
十、执行安装
pip3 install -i http://103.45.102.36:10080/simple/ tornado --trusted-host 103.45.102.36
本地直接安装, 不保证能成功,或者出现别的问题,曾经尝试此种方法后, 打包失败,不确定是不是这里引起的
pip3 install --no-index --find-links=/opt/pypi/ tornado
网友留言: