Create the LNMP with Docker (Use the php5.3, 5.6, 7.2 to deployment is available) || 使用Docker快速构建包含PHP多版本的LNMP环境(PHP5.3, 5.6, 7.2)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
conf
php
site
src
.gitignore
LICENSE
README.md
docker-compose.yml

README.md

docker-lnmp-with-mutli-php-versions

(中文版说明)

Because of my work needs, I need to maintain somw old system which use php5.3, so I need a more rapid deployment system tools. And that's what I going to share with you.

Create the LNMP with Docker (Use the php5.3, 5.6, 7.2 to deployment is available)

                 +- - - - - - - - - - - - - - - - - - - - - - - -+
                 ' docker:                                       '
                 '                                               '
+------+  80     ' +-------+    9000    +-----------+            '
|      | ------> ' |       |   <------> | PHP-FPM53 | <------+   '
|      |         ' |       |            +-----------+        |   '
|      |         ' |       |    9000    +-----------+        |   '
|      |         ' |       |   <------> | PHP-FPM56 | <------+   '
|      |         ' | Nginx |            +-----------+        |   '
| User |         ' |       |    9000    +-----------+        |   '
|      |         ' |       |   <------> | PHP-FPM72 | <------+   '
|      |         ' |       |            +-----------+        |   '
|      |         ' |       |                                 |   '
|      |         ' +-------+                                 |   '
|      |  3306   ' +-------+    3306                         |   '
|      | ------> ' | Mysql |   <-----------------------------+   '
+------+         ' +-------+                                     '
                 '                                               '
                 +- - - - - - - - - - - - - - - - - - - - - - - -+

Feature

  1. Multiple PHP version can be one-time deployment.
  2. All Configuration/Log files are stored in the host.
  3. MySQL Data are stored in the host.

Requirement

Deploy

  1. Clone Project:
$ git clone https://github.com/copriwolf/docker-lnmp-with-mutli-php-versions.git
  1. Go into the project & Start docker compose:
$ cd docker-lnmp-with-mutli-php-versions
$ docker-compose up
  1. Check the URL localhost in you browser, and you will catch the phpinfo with 7.2:

the php7.2 site files is in ./site/site1

Preview other php version website?

  1. You can add these hosts in your system.

hosts file location: Linux & Mac in /etc/hosts, Windows in C:\Windows\System32\drivers\etc (default)

127.0.0.1 www.site1.com
127.0.0.1 www.site2.com
127.0.0.1 www.site3.com
  1. Then go to your browser and type www.site2.com or www.site3.com, you will catch the php5.6 & php5.3.

Create a php53/php56/php72 website?

In fact I am using the Nginx conf file to control the version of PHP. You can check the .conf/nginx/conf.d/site1.conf, and found I fill the fpm72:9000 as the fastcgi_pass. So you can use fpm53:9000/fpm56:9000/fpm72:9000 to create a php53/php56/php72 website if you want.

Here is a example for creating a php53 site:

  1. Copy a conf file from site3.conf

If you want to create a php56/php72 site? Refer to site2.conf/site1.conf

$ cp ./conf/nginx/conf.d/site3.conf ./conf/nginx/conf.d/youDomainName.conf
  1. Edit the field server_name(Your WebSite Domain) & root(Your WebSite Root Directory) in conf file:

  2. Create the Site Web Root Directory

$ mkdir ./site/youDomainName
  1. Put the web files into the Directory
  2. Restart the docker
$ docker-compose restart

Acknowledgement