Usage scenario description: In 2014, when the company was founded, we took on an order management system for enterprise content. At that time, we used the latest technologies: Ubuntu 16.04, Laravel 4, PHP 5.6, Nginx, and MySQL 5.7. But time flies, and some technologies become outdated. It is 2025 now. If at this time, the customer’s system finally crashes after 10 years of operation because the computer hardware is outdated and cannot be turned on, what should be done?
Buy a new computer host, install Ubuntu 16.04, PHP 5.6, MySQL 5.7, and then redeploy the project created with Laravel. Is it that easy? Those who have actually encountered similar problems know that there will be many problems that are not easy to overcome. The most troublesome thing is that the software package used at the beginning cannot be found, so the system cannot be restored. It is also possible that many technical documents for building a program runtime environment from 10 years ago are no longer available, making it difficult to build a complete runtime environment.
Using Docker to solve this problem
I want to use different Docker Containers to build the environment required to run the order system.
- I built a Docker Image for Linux running PHP 5.6
- I built a Docker Image running Nginx
- I built a Docker Image running MySQL 5.7

version: '3.8'
services:
php:
image: fluber/fahua_docker-php:latest
networks:
- app-network
command: php-fpm
nginx:
image: nginx:latest
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/sites-available/default:/etc/nginx/conf.d/default.conf:ro
- ./ams:/var/www/ams
- ./init.sh:/usr/local/bin/init.sh # 將腳本掛載到容器中
ports:
- "80:80"
depends_on:
- php
networks:
- app-network
command: /bin/bash /usr/local/bin/init.sh # 執行腳本
db:
image: mysql:5.7
container_name: mysql-db
restart: always
environment:
MYSQL_ROOT_PASSWORD: amsuser456
MYSQL_DATABASE: AmsSchema
MYSQL_USER: amsuser
MYSQL_PASSWORD: amsuser456
volumes:
- db_data:/var/lib/mysql
- ./db/my.conf:/etc/mysql/my.cnf
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- app-network
ports:
- "3306:3306"
networks:
app-network:
driver: bridge
volumes:
db_data:
Docker Image: PHP5.6 + Ubuntu
I created a Dockerfile for PHP5.6 + Ubuntu, you can check the following code snippet. The deployment path of the order system I set in Dockerfile and the settings of php.ini and xdebug.ini
- Dockerfile
- php.ini
- xdebug.ini
# Dockerfile
FROM php:5.6-fpm
# 替換過期的 apt 源,移除 stretch-updates
RUN sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list && \
sed -i '/stretch-updates/d' /etc/apt/sources.list && \
sed -i '/security.debian.org/d' /etc/apt/sources.list && \
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until && \
apt-get update
# 安裝系統依賴和 PHP 擴展
RUN apt-get install -y \
libpng-dev libjpeg-dev libfreetype6-dev \
zip unzip git curl wget vim \
libmcrypt-dev libtool autoconf automake \
&& apt-get clean
# 手動安裝 Mcrypt for PHP 5.6
RUN mkdir -p /usr/src/php/ext/mcrypt && \
curl -fsSL https://pecl.php.net/get/mcrypt-1.0.1.tgz | tar xvz -C /usr/src/php/ext/mcrypt --strip 1 && \
docker-php-ext-install mcrypt
# 安裝其他 PHP 擴展
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install gd mbstring pdo pdo_mysql zip
# 設定工作目錄並複製 Laravel 應用
WORKDIR /var/www/ams
COPY ams /var/www/ams
# 設定 Laravel 儲存目錄的權限
RUN chown -R www-data:www-data /var/www/ams && \
chmod -R 775 /var/www/ams/app/storage
# 複製 PHP 設定檔
COPY php/php.ini /etc/php/5.6/fpm/php.ini
COPY php/php.ini /etc/php/5.6/cli/php.ini
COPY php/php.ini /etc/php/5.6/apache2/php.ini
# 複製 Xdebug 設定
COPY php/xdebug.ini /etc/php/5.6/mods-available/xdebug.ini
# 開放 9000 端口給 PHP-FPM 使用
EXPOSE 9000
# 啟動 PHP-FPM 服務
CMD ["php-fpm"]
# php.ini
[PHP]
max_execution_time = 300
max_input_time = 300
memory_limit = 256M
post_max_size = 50M
upload_max_filesize = 50M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
error_log = /var/log/php_errors.log
date.timezone = "Asia/Taipei"
[opcache]
opcache.enable = 1
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 60
opcache.validate_timestamps = On
[cli]
memory_limit = 256M
[mail function]
SMTP = smtp.yourdomain.com
smtp_port = 25
sendmail_path = "/usr/sbin/sendmail -t -i"
# xdebug.ini
zend_extension=/usr/lib/php56/modules/xdebug.so
xdebug.idekey="Code"
xdebug.default_enable=on
xdebug.remote_connect_back=on
xdebug.remote_port=9000
xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_handler="dbgp"
Recovery Drills
The data in the database will continue to change, and some new images will be added to Laravel, so I will back up the database and Laravel’s program running environment at the beginning of each month.
In addition, because the actual database connection information is different from the Docker recovery environment, the database connection settings need to be adjusted when performing disaster recovery testing.
- Unzip the Laravel runtime environment program
- Modify database connection information
- Run Docker
- Unzip the database backup data
- Importing a database using the workbench tool
- Running the test scenario





Docker Container program running screen

Laravel program running screen

I would like to share with you the disaster recovery cases that I perform every month in my practice. I hope it can be of some help.
PHP5 website technical support expires in 2019, and may become a security orphan. PHP Supported Version.
MySQL 5.6 End of Support. MySQL Supported Version.
If you think it is well written, please forward this article.