docker lnmp lamp 搭建

8 篇文章 0 订阅

镜像的构建是基于centos7.2镜像,然后yum安装lnmp

lnmp 环境

php7.0

yum安装 lnmp软件参考我的另外一篇博客 

https://blog.csdn.net/luolaifa000/article/details/86657353

登录阿里云Docker Registry
$ sudo docker login --username=yumancang1 registry.cn-hangzhou.aliyuncs.com
从Registry中拉取镜像
$ sudo docker pull registry.cn-hangzhou.aliyuncs.com/yumancang/lnmp:[镜像版本号]

#启动容器,挂载目录,端口映射
docker run -dit -p 80:80 --name weblamp_v1 -v /mnt/windows:/usr/share/nginx/html 87c441e26298
(启动容器后,容器内的服务不会自动启动,需要手动开启服务)

#进入容器
docker exec -it c34c009b5a3c /bin/bash
#启动NGINX
/usr/sbin/nginx -c /etc/nginx/nginx.conf
#启动PHP-FPM
/usr/sbin/php-fpm
#启动MYSQL
/usr/sbin/mysqld -uroot

pkill php-fpm

pkill mysqld

shell启动和关闭脚本:

#!/bin/bash

function stop() {
    pkill nginx
    pkill php-fpm
    action "Stop nginx" /bin/false
    action "Stop nginx" /bin/false
    return $?
}

function start() {
    /usr/sbin/nginx -c /etc/nginx/nginx.conf
    /usr/sbin/php-fpm
    return $?
}

function restart() {
    stop()
    start()
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 2
esac

 

 

lamp环境

http

查看httpd包是否可用:

# yum list | grep httpd

 

安装Apache

# yum install httpd

php5.6.40

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# yum list php* 可以发现里面有很多版本的php 选择对应的安装的包

# yum -y install php56w php56w-mysql php56w-gd libjpeg* php56w-ldap php56w-odbc php56w-pear php56w-xml php56w-xmlrpc php56w-mbstring php56w-bcmath

登录阿里云Docker Registry
$ sudo docker login --username=yumancang1 registry.cn-hangzhou.aliyuncs.com
从Registry中拉取镜像
$ sudo docker pull registry.cn-hangzhou.aliyuncs.com/yumancang/lamp:[镜像版本号]

#启动容器,挂载目录,端口映射
docker run -dit -p 80:80 --name weblamp_v1 -v /mnt/windows/gitlab:/var/www/html 48b1d55f4327
(启动容器后,容器内的服务不会自动启动,需要手动开启服务)

#进入容器
docker exec -it c34c009b5a3c /bin/bash
#启动apache
/usr/sbin/httpd
#启动MYSQL
/usr/sbin/mysqld -uroot

pkill httpd

pkill mysqld

shell启动和关闭脚本

#!/bin/bash

function stop() {
    pkill httpd
    action "Stop httpd" /bin/false
    return $?
}

function start() {
    /usr/sbin/httpd
    return $?
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 2
esac

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值