Ubuntu16.04搭建gitlab服务器,搭建pip源服务器(两种方式),搭建apt源服务器

简介: 这篇文章是关于如何在Ubuntu 16.04系统上搭建GitLab服务器、pip源服务器(使用pypiserver和NGINX两种方式),以及apt源服务器的详细教程。

前言

因为要换工作地方,单位最近两天要我部署了gitlab服务器,pip源服务器,搭建apt源服务器。现在已经全部搞定,中间遇到了不少坑,特来记录一番。

一、环境叙述

Linux系统:ubuntu16.0.4
username: feng
python 3.6.9
pip 3.6

二、搭建gitlab服务器

下载Ubuntu软件的地址,推荐一下:
curl下载地址:https://curl.haxx.se/download.html
openssh-server、ca-certificates、postfix下载地址:https://pkgs.org/

  1. 安装依赖包
    命令安装:sudo apt-get install curl openssh-server ca-certificates postfix
    离线安装:先解压,在编译安装
    安装postfix

  2. Gitlab下载
    https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/trusty/main/g/gitlab-ce/
    汉化包下载
    https://gitlab.com/xhang/gitlab/-/archive/10-8-stable-zh/gitlab-10-8-stable-zh.tar.bz2

  3. 安装gitlab-ce_10.8.7-ce.0_amd64.deb
    sudo dpkg -i gitlab-ce_10.8.7-ce.0_amd64.deb
    在这里插入图片描述

  4. 根据提示更改 external_url 外部可以访问的本机地址
    sudo vi /etc/gitlab/gitlab.rb
    在这里插入图片描述

  5. 重新配置Gitlab以使更改生效
    sudo gitlab-ctl reconfigure

  6. 重新启动服务
    sudo gitlab-ctl restart

  7. 测试访问
    在这里插入图片描述

  8. 解压汉化包
    tar xf gitlab-10-8-stable-zh.tar.bz2

  9. 安装汉化包
    sudo cp -rf gitlab-10-8-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/

  10. 重新配置Gitlab以使更改生效
    sudo gitlab-ctl reconfigure

  11. 重新启动服务
    sudo gitlab-ctl restart

  12. 测试
    在这里插入图片描述

  13. 注意:提示502如上截图信息是因为内存太低导致,修改服务器内存配置,并F5多刷新几次即可
    在这里插入图片描述
    初次登录会让你设置密码
    密码不能太短,我设置的是root12345678

  14. 完全卸载Gitlab

复制代码

停止gitlab

sudo gitlab-ctl stop

查看进程

ps -e | grep gitlab

删除所有包含gitlab的文件及目录

find / -name gitlab | xargs rm -rf

卸载

sudo apt-get remove gitlab-ce

检查还有没有卸载的gitlab相关软件

dpkg --get-selections | grep gitlab
gitlab-ce deinstall

再执行

sudo apt-get --purge remove gitlab-ce

三、搭建pip源服务器

1. 使用pypiserver搭建

  1. cd /home/feng
  2. mkdir pypiserver
  3. 将pypiserver-1.3.2-py2.py3-none-any.whl 移动到pypiserver目录中
  4. cd pypiserver
  5. 安装python包 pip install pypiserver-1.3.2-py2.py3-none-any.whl。
  6. 进入到家目录下 cd …
  7. 创建packages目录,用于存放包, mkdir packages
  8. 往里面放一个包 py_trees-2.0.13-py3-none-any.whl 用于测试
  9. 进入到 pypiserver 目录 后台启动:nohup pypi-server -p 8082 ~/packages &
  10. 打开浏览器 输入 本机ip:8082/simple/ 或者localhost:8082/simple/ 出现如下图,则启动成功。
    在这里插入图片描述
  11. 测试装包

回到家目录下。cd /home/feng
配置pip源仓库地址
打开pip.conf :vim .pip/pip.conf
更改如下:
[global]
index-url = http:// 10.18.10.35:8082/simple
[install]
trusted-host=10.18.10.35:8082
保存退出即可。
使用命令 安装 py_trees 包:pip install py_trees
有可能会出现如下报警
在这里插入图片描述
则安装提示 在后面添加参数 --trusted-host 10.18.10.35
在这里插入图片描述
出现上面如图所示,则安装成功。
查看安装的包 : pip show py_trees。
在这里插入图片描述

2. 使用NGINX 代理搭建

四、搭建apt源服务器

总体来说,分三步走
1、将通过apt-mirror将外网下的apt源包都拉取下来。
2、安装nginx,使用nginx 将apt源包反向代理出去。
3、局域网内的机器配置本地镜像源,进行安装使用

1. 安装配置apt-mirror

1、先确认需要下载的镜像源的名称,可以从https://help.ubuntu.com查询
在这里插入图片描述
2、在ubuntu下安装apt-mirror
方式一sudo apt-get install apt-mirror
方式二 下载安装包
3、修改apt-mirror 配置文件
sudo vim /etc/apt/mirror.list
我的配置文件如下

############# config ##################
# 以下注释的内容都是默认配置,如果需要自定义,取消注释修改即可
# set base_path    /var/spool/apt-mirrorset base_path  /opt/mirror/ubuntu
#
# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var
# set cleanscript $var_path/clean.sh
# 架构配置,i386/amd64,默认下载与本机相同的架构
# set defaultarch amd64
# set defaultarch  <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############
# 下载18.04版本的镜像源bionic,如果需要其他版本,将bionic替换成对应版本的英文名称即可。名称从https://help.ubuntu.com/查询
deb-i386 http://mirrors.aliyun.com/ubuntu bionic main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu bionic-security main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu bionic-updates main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu bionic-proposed main restricted universe multiverse
deb-i386 http://mirrors.aliyun.com/ubuntu bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu bionic-backports main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu bionic main restricted universe multiverse #deb-src http://mirrors.aliyun.com/ubuntu bionic-security main restricted universe multiverse #deb-src http://mirrors.aliyun.com/ubuntu bionic-updates main restricted universe multiverse #deb-src http://mirrors.aliyun.com/ubuntu bionic-proposed main restricted universe multiverse #deb-src http://mirrors.aliyun.com/ubuntu bionic-backports main restricted universe multiverse  clean http://mirrors.aliyun.com/ubuntu

4、创建镜像的本地目录(根据配置文件中配置的路径来创建目录)
sudo mkdir -p /opt/mirrors/ubuntu
5、开始拉取镜像
sudo apt-mirror

2. 本地镜像源的部署

1、安装web服务器(nginx)
方式一:sudo apt-get installnginx
方式二:解压编译nginx1.8
2、配置web服务
对应安装方式一:sudo vi /etc/nginx/site
对应安装方式二:sudo vi /usr/local/nginx/conf/nginx.conf
配置如下

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        server_name _;

        location / {
                try_files $uri $uri/ =404;
                autoindex on;
                autoindex_exact_size off;
                autoindex_localtime on;
        }
}

3、镜像服务挂载
sudo ln -s /opt/mirrors/ubuntu/mirror/mirrors.aliyun.com/ubuntu /var/www/html/ubuntu
4、重启nginx服务
cd /usr/local/nginx/sbin/
sudo ./nginx
使用浏览器访问http://localhost ,如果看到nginx的欢迎页面,则nginx启动成功
使用浏览器访问 http://localhost/ubuntu , 应该可以在web界面看到本地仓库中的软件包。

3. 局域网机器使用本地镜像源

1、修改apt配置文件
sudo vim /etc/apt/sources.list
参考配置如下(127.0.0.1替换成前面部署的机器ip):

deb http://127.0.0.1/ubuntu/ bionic main restricted universe multiverse
deb http://127.0.0.1/ubuntu/ bionic-updates main restricted universe multiverse
deb http://127.0.0.1/ubuntu/ bionic-backports main restricted universe multiverse
deb http://127.0.0.1/ubuntu/ bionic-security main restricted universe multiverse
deb http://127.0.0.1/ubuntu/ bionic-proposed main restricted universe multiverse

2、更新系统
sudo apt-get upgrade
3、更新软件索引
sudo apt-get update
4、软件安装
sudo apt-get install XXX(软件名)

相关文章
|
4天前
|
缓存 NoSQL Ubuntu
大数据-39 Redis 高并发分布式缓存 Ubuntu源码编译安装 云服务器 启动并测试 redis-server redis-cli
大数据-39 Redis 高并发分布式缓存 Ubuntu源码编译安装 云服务器 启动并测试 redis-server redis-cli
24 3
|
5天前
|
Ubuntu API Python
Chat-TTS chat-tts-ui 实机部署上手测试!Ubuntu服务器实机 2070Super*2 8GB部署全流程
Chat-TTS chat-tts-ui 实机部署上手测试!Ubuntu服务器实机 2070Super*2 8GB部署全流程
25 1
|
5天前
|
并行计算 Ubuntu 算法
Ubuntu18 服务器 更新升级CUDA版本 pyenv nvidia ubuntu1804 原11.2升级到PyTorch要求12.1 全过程详细记录 apt update
Ubuntu18 服务器 更新升级CUDA版本 pyenv nvidia ubuntu1804 原11.2升级到PyTorch要求12.1 全过程详细记录 apt update
23 0
|
6天前
|
Ubuntu
Ubuntu修复-boot满了导致apt坏掉的问题
Ubuntu修复-boot满了导致apt坏掉的问题
|
6天前
|
Ubuntu Linux 数据安全/隐私保护
Ubuntu搭建vscode服务器
Ubuntu搭建vscode服务器
|
6天前
|
Web App开发 Ubuntu Linux
Ubuntu搭建vscode服务器
Ubuntu搭建vscode服务器
|
7天前
|
Ubuntu Linux Windows
Ubuntu 14.04安装samba服务器
Ubuntu 14.04安装samba服务器
12 0
|
7天前
|
网络安全
Ubuntu14.04安装ssh服务器
Ubuntu14.04安装ssh服务器
17 0
|
28天前
|
Ubuntu 开发工具 git
在Ubuntu上部署BOA服务器的步骤
部署BOA服务器是一个涉及多个步骤的过程,包括系统更新、安装依赖、下载和编译源代码、配置服务器以及启动和验证。遵循上述步骤,可以在Ubuntu系统上成功部署BOA服务器,为开发和测试提供一个轻量级的Web服务器环境。
22 0
|
弹性计算 Ubuntu 前端开发
ECS使用体验----搭建GitLab
云服务器ECS(Elastic Compute Service)是阿里云提供的性能卓越、稳定可靠、弹性扩展的IaaS(Infrastructure as a Service)级别云计算服务。云服务器ECS免去了您采购IT硬件的前期准备,让您像使用水、电、天然气等公共资源一样便捷、高效地使用服务器,实现计算资源的即开即用和弹性伸缩。阿里云ECS持续提供创新型服务器,解决多种业务需求,助力您的业务发展。
395 1
ECS使用体验----搭建GitLab