1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 创建一个运行 PHP NGINX 和 Hip Hop VM(HHVM) 的 Docker 容器

创建一个运行 PHP NGINX 和 Hip Hop VM(HHVM) 的 Docker 容器

时间:2022-05-17 22:47:27

相关推荐

创建一个运行 PHP  NGINX 和 Hip Hop VM(HHVM) 的 Docker 容器

php教程|php手册

创建,一个,运行,PHP,NGINX,Hip,Hop,HHV

php教程-php手册

erp系统源码 php,ubuntu挂载iso例子,tomcat分不分系统,爬虫淘宝页面,php 解释html,泛站群seo优化是什么意思lzw

作者:Mike Ebinum 译者:叶可强 对于 Docker,我感到非常的兴奋。作为一个很早就进行 .NET 开发的开发人员,我工作中不喜欢的事情之一就是在不同的环境中部署和测试。部署一个 web 应用程序的过程绝对是一个噩梦般的经历。即便之后我迁移到基于 UNIX 平台开

12306 抢票源码 java,m1支持vscode吗,ubuntu 磁盘占用,部署tomcat到环境上,爬虫post,php 大文件断点上传,seo网站优化推广排名教程lzw

稳定 远控 源码,vscode抓取网页源码,ubuntu移植2440,停止所有的tomcat,delpi爬虫,php祝福墙,付费seo推广及优化,mac下载网站源文件,在线考试系统首页模板lzw

作者:Mike Ebinum
译者:叶可强

Dockerfile

准备开始,我们创建一个Dockerfile—— Dockerfile 包含如何创建所需镜像的指令。

FROM centos:centos6MAINTAINER Mike Ebinum, hello@seedtech.io

使用 Cent OS 6.x

告知 Docker 使用官方社区最新版本的 CentOS 6.x 可用镜像。

更新镜像

安装所有最新版本的包更新,并且把 Red Hat EPEL 的仓库加入可用的仓库列表。

RUN yum update -y >/dev/null && yum install -y http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm && curl -L -o /etc/yum.repos.d/hop5.repo "http://www.hop5.in/yum/el6/hop5.repo"

安装包

安装supervisord—— 我们将使用这个配置和控制运行在容器中的进程 – 、 nginx 、 php 、一些 PHP 的开发包以及 Facebook 的 hhvm 。

RUN yum install -y python-meld3 /pub/epel/6/i386/supervisor-2.1-8.el6.noarch.rpmRUN ["yum", "-y", "install", "nginx", "php", "php-mysql", "php-devel", "php-gd", "php-pecl-memcache", "php-pspell", "php-snmp", "php-xmlrpc", "php-xml","hhvm"]

配置 Nginx 、 HHVM 和 Supervisord

为 nginx 创建目录,并且把index.php文件加入 nginx 来展现。

RUN mkdir -p /var/www/html && chmod a+r /var/www/html && echo "" > /var/www/html/index.php

下一组指令是:

为 HHVM 添加一个配置文件,然后重启我们的 HHVM 服务

为 Supervisord 添加一个配置文件,然后启动 Nginx 和 HHVM

ADD config.hdf /etc/hhvm/config.hdf RUN service hhvm restart ADD nginx.conf /etc/nginx/conf.d/default.conf ADD supervisord.conf /etc/supervisord.conf RUN chkconfig supervisord on && chkconfig nginx on

添加一个 shell 脚本/run.sh,在 Docker 容器运行时启动。

run.sh

#!/bin/bashset -e -x echo "starting supervisor in foreground" supervisord -n

ADD scripts/run.sh /run.sh RUN chmod a+x /run.sh EXPOSE 22 80 ENTRYPOINT ["/run.sh"]

构建容器,并且打 tag

docker build -t centos-nginx-php5-hhvm .

现在我们有一个全功能的容器,我们可以像下面这样运行:

docker run -d -p 80:80 centos-nginx-php5-hhvm

如果你已经有本地的服务已经在运行并且占用了 80 端口,你能很容易的的改变容器的对外端口。

Dockerfile

完整的 Dockerfile 如下

# DOCKER-VERSION 1.0.0FROM centos:centos6MAINTAINER Mike Ebinum, hello@seedtech.io# Install dependencies for HHVM# yum update -y >/dev/null && RUN yum install -y /pub/epel/6/i386/epel-release-6-8.noarch.rpm && curl -L -o /etc/yum.repos.d/hop5.repo "http://www.hop5.in/yum/el6/hop5.repo"# Install supervisorRUN yum install -y python-meld3 /pub/epel/6/i386/supervisor-2.1-8.el6.noarch.rpm#install nginx, php, mysql, hhvmRUN ["yum", "-y", "install", "nginx", "php", "php-mysql", "php-devel", "php-gd", "php-pecl-memcache", "php-pspell", "php-snmp", "php-xmlrpc", "php-xml","hhvm"]# Create folder for server and add index.php file to for nginxRUN mkdir -p /var/www/html && chmod a+r /var/www/html && echo "" > /var/www/html/index.php#Setup hhvm - add config for hhvmADD config.hdf /etc/hhvm/config.hdf RUN service hhvm restart# ADD Nginx configADD nginx.conf /etc/nginx/conf.d/default.conf# ADD supervisord config with hhvm setupADD supervisord.conf /etc/supervisord.conf#set to start automatically - supervisord, nginx and mysqlRUN chkconfig supervisord on && chkconfig nginx onADD scripts/run.sh /run.shRUN chmod a+x /run.sh EXPOSE 22 80 #Start supervisord (which will start hhvm), nginx ENTRYPOINT ["/run.sh"]

在这篇文章中提到的其他的可用文件在 Github 上。

下一步?

太棒了!我们现在有了一个环境配置,但我如何运行 PHP 应用程序?我将做后续的文章介绍如何使用这个容器来安装和配置 PHP 应用程序。欢迎订阅这个 博客,也可以在在 twitter 关注 @mikeebinum 和 @SEEDtechio 来获得更新。

这篇文章由 Mike Ebinum 撰写,叶可强 翻译。点击 这里 阅读原文。
The article was contributed by Mike Ebinum, click here to read the original publication.

原文地址:创建一个运行 PHP 、NGINX 和 Hip Hop VM(HHVM) 的 Docker 容器, 感谢原作者分享。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。