Docker under PHP+NGINX+HHVM operating environment

Source: Internet
Author: User
Tags hhvm phpinfo snmp docker run docker registry

Dockerfile

To get started, we create a dockerfile--dockerfile that contains instructions on how to create the desired image.


From CENTOS:CENTOS6
Maintainer Mike ebinum, [email protected]


Using Cent OS 6.x

Tell Docker to use the latest version of the CentOS 6.x available image from the official community.

Update image

Install all latest versions of package updates and add Red Hat EPEL's warehouses to the list of available warehouses.


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"


Install package

Install supervisord--We will use this to configure and control the processes running in the container--Nginx, PHP, some PHP development kits, and Facebook's HHVM.


RUN Yum install-y python-meld3 http://dl.fedoraproject.org/pub/epel/6/i386/supervisor-2.1-8.el6.noarch.rpm
RUN ["Yum", "Y", "Install", "Nginx", "PHP", "Php-mysql", "Php-devel", "PHP-GD", "Php-pecl-memcache", "Php-pspell", "php- SNMP "," Php-xmlrpc "," Php-xml "," HHVM "]


Configuring Nginx, HHVM, and Supervisord

Create a directory for Nginx, and add the index.php file to Nginx to show.


RUN mkdir-p/var/www/html && chmod a+r/var/www/html && echo "<?php phpinfo ();?>" >/var/www/ht ml/index.php


The next set of instructions is:

Add a profile for HHVM and then restart our HHVM service

Add a profile for Supervisord, and then start Nginx and 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


Add a shell script/run.sh, which starts when the Docker container is running.

run.sh


#!/bin/bash
SET-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"]


Build the container and hit tag


Docker build-t CENTOS-NGINX-PHP5-HHVM.


Now we have a full-featured container that we can run like this:


Docker run-d-P 80:80 CENTOS-NGINX-PHP5-HHVM


If you already have a local service already running and occupy 80 ports, you can easily change the container's external port.

Docker Registry provides the available version of this Docker image.

Dockerfile

The complete Dockerfile is as follows


# docker-version 1.0.0
From CENTOS:CENTOS6
Maintainer Mike ebinum, [email protected]
# Install dependencies for HHVM
# yum Update-y >/dev/null &&
RUN Yum install-y http://dl.fedoraproject.org/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 Supervisor
RUN Yum install-y python-meld3 http://dl.fedoraproject.org/pub/epel/6/i386/supervisor-2.1-8.el6.noarch.rpm
#install nginx, PHP, MySQL, HHVM
RUN ["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 Nginx
RUN mkdir-p/var/www/html && chmod a+r/var/www/html && echo "<?php phpinfo ();?>" >/var/www/ht ml/index.php
#Setup hhvm-add config for HHVM
ADD CONFIG.HDF/ETC/HHVM/CONFIG.HDF
RUN Service HHVM Restart
# ADD Nginx Config
ADD nginx.conf/etc/nginx/conf.d/default.conf
# ADD Supervisord config with HHVM setup
ADD supervisord.conf/etc/supervisord.conf
#set to start Automatically-supervisord, Nginx and MySQL
RUN chkconfig Supervisord on && chkconfig nginx on
ADD scripts/run.sh/run.sh
RUN chmod a+x/run.sh
EXPOSE 22 80
#Start Supervisord (which'll Start HHVM), Nginx
entrypoint ["/run.sh"]

Docker under PHP+NGINX+HHVM operating environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.