Centos 7 搭建Nginx , Docker (装rabbitMq,postgresql , gitlab镜像)

来源:互联网 发布:php商城框架 编辑:程序博客网 时间:2024/06/05 03:29

前言:
连接工具xshell

Nginx部署

//说明如果你是裸机的话,通过下面这个博文部署ngxin 的时候,会出现一些基本环境问题(1)linux下安装安装pcre-8.32./configure --prefix=/usr/local/pcre 出现以下错误configure: error: You need a C++ compiler for C++ support正解yum install -y gcc gcc-c++(2) make出错make: *** No rule to make target `build', needed by `default'.  Stop../configure: error: SSL modules require the OpenSSL library.You can either do not enable the modules, or install the OpenSSL libraryinto the system, or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl=<path> option.ubuntu下解决办法:apt-get install opensslapt-get install libssl-devcentos下解决办法:yum -y install openssl openssl-devel

http://www.runoob.com/linux/nginx-install-setup.html

Docker部署

安装docker,运行[root@localhost ~]# yum install docker安装完成,查看docker版本信息,运行 [root@localhost ~]# docker version,看到以下信息表示安装成功

这里写图片描述

启动docker,运行[root@localhost ~]# systemctl start docker.service设置为开机启动,运行[root@localhost ~]# systemctl enable docker.service
修改docker加速镜像为阿里云, 使用docker pull,命令下载镜像太慢了,默认是从国外的,下如何配置国内阿里云竞相加速方式。方法1、编辑/etc/systemd/system/multi-user.target.wants/docker.service文件,找到 ExecStart= 这一行,在这行最后添加加速器地址 –registry-mirror=<加速器地址>,如:ExecStart=/usr/bin/dockerd --registry-mirror=https://xxxxx.mirror.aliyuncs.com方法2/** *说明: 运行此命令要回到 根目录 **/[root@localhost ~]# sed -i "s|ExecStart=/usr/bin/dockerd|ExecStart=/usr/bin/dockerd --registry-mirror=https://ihzk22je.mirror.aliyuncs.com|g" /etc/systemd/system/multi-user.target.wants/docker.service修改后重新加载配置,运行[root@localhost ~]#systemctl daemon-reload;重新启动服务,运行[root@localhost ~]#systemctl restart docker即可。

安装rabbitmq

[root@localhost ~]# docker search rabbitmq

这里写图片描述

[root@localhost ~]# docker pull rabbitmq:management[root@localhost ~]# docker pull rabbitmq:3-management

这里写图片描述

查看镜像[root@localhost ~]# docker images

这里写图片描述

运行rabbitmq[root@localhost ~]# docker run -d --name myrabbitmq -p 5673:5672 -p 15673:15672    docker.io/rabbitmq:3-managementmyrabbitmq (该名字随意起)docker.io/rabbitmq:3-management (此为:docker images 结果下的: REPOSITORY:TAG)如果启动失败,查看原因,可能是端口被占用说明: docker run .....为创建一个容器

Docker 容器管理命令:

查看所有容器[root@localhost ~]# docker ps -a查看正在运行的容器(显示所有信息)[root@localhost ~]# docker ps查看正在运行的容器(只显示CONTAINER ID)[root@localhost ~]# docker ps -q停止所有正在运行的容器[root@localhost ~]# docker stop $( docker ps -q)删除容器[root@localhost ~]# docker rm 容器名字停止一个容器[root@localhost ~]# docker stop 容器名字开启一个容器[root@localhost ~]# docker start 容器名字删除镜像停止所有的container,这样才能够删除其中的images:[root@localhost ~]# docker stop $(docker ps -a -q)删除images,通过image的id来指定删除谁[root@localhost ~]# docker rmi <image id>要删除全部image的话[root@localhost ~]# docker rmi $(docker images -q)
查看[root@localhost ~]# docker ps

这里写图片描述

浏览器中访问 http://http://123.206.66.232:15673  默认用户名guest密码guest

这里写图片描述

安装Postgresql镜像

安装postgres[root@localhost ~]# docker pull postgres:9.4
安装容器[root@localhost ~]# docker run --name postgres1 -e POSTGRES_PASSWORD=password -p 54321:5432 -d postgres:9.4 说明:run,创建并运行一个容器; --name,指定创建的容器的名字; -e POSTGRES_PASSWORD=password,设置环境变量,指定数据库的登录口令为password; -p 54321:5432,端口映射将容器的5432端口映射到外部机器的54321端口; -d postgres:9.4,指定使用postgres:9.4作为镜像。
验证结果[root@localhost ~]# docker ps -a

这里写图片描述
注意:
连接postgresql 的时候,postgres镜像默认的用户名为postgres,端口为54321 (它会映射到5432)。

安装Gitlab镜像

[root@localhost ~]# docker search gitlab,查看镜像

这里写图片描述

[root@localhost ~]# docker pull sameersbn/gitlab:latest,pull镜像文件,运行完成后,运行

这里写图片描述

[root@localhost ~]# docker images如下图所示:

这里写图片描述

添加gitlab容器提示:gitlab 启动需要2G内存如果服务器内存不足,gitlab将无法启动[root@localhost ~]# docker run -d --publish 1443:443 --publish 18080:80 --publish 10022:22 --name mygitlab --restart always gitlab/gitlab-ce:latest 
[root@localhost ~]# docker ps查看是否启动成功

这里写图片描述

在浏览器输入http://192.168.1.129:18080/ 即可访问,修改初始密码

这里写图片描述

阅读全文
0 0
原创粉丝点击