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 | <-----------------------------+ '
+------+ ' +-------+ '
' '
+- - - - - - - - - - - - - - - - - - - - - - - -+
- Multiple PHP version can be one-time deployment.
- All Configuration/Log files are stored in the host.
- MySQL Data are stored in the host.
- Clone Project:
$ git clone https://github.com/copriwolf/docker-lnmp-with-mutli-php-versions.git
- Go into the project & Start docker compose:
$ cd docker-lnmp-with-mutli-php-versions
$ docker-compose up
- 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
- You can add these
hosts
in your system.
hosts file location: Linux & Mac in
/etc/hosts
, Windows inC:\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
- Then go to your browser and type
www.site2.com
orwww.site3.com
, you will catch the php5.6 & php5.3.
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:
- Copy a conf file from site3.conf
If you want to create a
php56
/php72
site? Refer tosite2.conf
/site1.conf
$ cp ./conf/nginx/conf.d/site3.conf ./conf/nginx/conf.d/youDomainName.conf
-
Edit the field
server_name
(Your WebSite Domain) &root
(Your WebSite Root Directory) in conf file: -
Create the Site Web Root Directory
$ mkdir ./site/youDomainName
- Put the web files into the Directory
- Restart the docker
$ docker-compose restart