程序员Docker容器linux&github

使用Docker搭建Apache+PHP+mysql+ssh环境

2019-05-10  本文已影响12人  米兰的小码农

1.Docker安装

2.CentOS服务器环境搭建

2.1启动Docker容器

2.2获取centos镜像

docker search centos
查找centos镜像
docker pull centos

2.3运行CentOS容器

docker run -itd -p 2222:22 -p 8888:80 --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup 9f38484d220f /usr/sbin/init /bin/bash
docker exec -it 9ad6608450b4 /bin/bash  

2.4安装wget

yum -y install wget

2.5安装mysql-community-release-el7-5.noarch.rpm包

cd /usr/local/src/
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm

2.6安装initscripts

yum list | grep initscripts
yum install initscripts -y

2.7安装mysql

yum install -y mysql-community-server
systemctl enable mysqld.service         // 设置开机启动
systemctl start mysqld.service       // 启动mysql服务

2.8安装apache

yum install httpd
systemctl enable httpd.service    // 设置开机启动
systemctl start httpd.service     // 启动httpd服务

2.8安装php

yum install php
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

2.9安装ssh服务端

yum install openssh-server
systemctl restart sshd     // 重启ssh服务
systemctl enable sshd    // 设置开机启动

3.保存容器镜像

docker ps
docker commit ae4ea5ef11c5 centos:v2
docker images centos

4.备注

上一篇 下一篇

猜你喜欢

热点阅读