我亏一点 - LAMP
type: channel
link: https://www.000081.xyz/index.php/tag/LAMP/
items: docker-compose部署LAMP环境(centos7+httpd+mysql5.7+php7.0)

docker-compose部署LAMP环境(centos7+httpd+mysql5.7+php7.0)
type: item
date: 2022-03-04T12:29:00+00:00
description: AI摘要 本文介绍了使用Docker Compose部署LAMP环境（CentOS 7、Apache、PHP 7.0、MySQL 5.7）的方法。通过编写Dockerfile构建包含Apache和PHP的自定义镜像，并配合docker-compose.yaml文件编排容器，实现了一键式快速部署与启动LAMP服务。 此内容根据文章生成，仅用于文章内容的解释与总结 docker-compose部署LAMP环境(centos7+httpd+mysql5.7+php7.0)Dockerfilecentos7+httpd(apache)+php7.0FROM centos:centos7.5.1804 MAINTAINER dao #配置yum源 centos源 RUN rm -rf /etc/yum.repos.d/* && curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && yum clean all && yum install -y wget vim net-tools #安装Apache和扩展包 RUN yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql #安装php RUN yum install -y \ https://repo.ius.io/ius-release-el7.rpm \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm --force --nodeps && yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb #编写启动脚本 RUN echo "#!/bin/bash" >> /start.sh && echo "php-fpm -R" >> /start.sh && echo "/usr/sbin/httpd -D FOREGROUND " >> /start.sh && \ chmod 777 /start.sh CMD ["sh", "-c", "source /start.sh"]镜像构建命令docker build -t 镜像名:镜像标签 .docker-compose.yaml文件version: '3.3' services: mariadb: image: mariadb:latest ports: - "3306:3306" restart: always environment: MYSQL_ROOT_PASSWORD: "root" #mysql的root密码 user: root php7.0: build: ./ # 也可以改成 image: 镜像名:镜像标签 user: root restart: always ports: - '80:80' - '443:443' - '9000:9000' - '8888:8888'容器启动命令docker-compose up -d打开服务器ip浏览即可