A method for building an LNMP environment based on Docker offline
By building offline image packages and toolkits, the problem of network limitations in setting up LNMP environments was solved, enabling rapid LNMP environment deployment without additional operations.
Patent Information
- Application Number
- CN202111344358.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-12
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2041-11-12
AI Technical Summary
In existing technologies, setting up an LNMP environment is limited by network constraints, and deployment to a test environment may encounter dependency or configuration file issues, leading to deployment difficulties.
By using PHP, MySQL, and Node images, an offline image package, a Docker installer, and a Docker Compose toolkit are built using Docker to form an installation file, which is then copied to the target server for execution to quickly build an LNMP environment.
It enables rapid offline setup of LNMP environments, avoiding network dependencies and configuration file issues, and achieving one-click deployment.
Smart Images

Figure CN116126453B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of development environment building, and particularly relates to a method for building an LNMP environment offline based on Docker. BACKGROUND
[0002] Web developers need to quickly build an LNMP environment, i.e., a development and running environment of a Linux system, Nginx, a MySQL database and a PHP programming language, in development, testing and operation. The built LNMP environment can normally run locally, but problems may occur in various dependencies or configuration files in the environment when it is published to a test environment. In addition, the building process is limited by the network, so it is necessary to build an LNMP environment that can successfully run anywhere. SUMMARY
[0003] The application provides a method for building an LNMP environment offline based on Docker to realize quick building of an LNMP environment in an offline state, aiming at the problems in the prior art that the building of an LNMP environment is limited by the network and problems may occur in various dependencies or configuration files in the environment when the LNMP environment is published to a test environment.
[0004] The technical solution provided by the application to solve the above technical problems is as follows: a method for building an LNMP environment offline based on Docker, comprising the following steps:
[0005] Step S1: using a PHP image, a MySQL image and a Node image to build an installation file through Docker, wherein the installation file comprises an offline image package, an offline Docker installation package, a Docker_compose tool package and an offline code package;
[0006] Step S2: copying the installation file to a target server;
[0007] Step S3: executing the installation file to verify whether the environment is built.
[0008] In the method for building an LNMP environment offline based on Docker provided by the application, the step S1 comprises:
[0009] Step S11: downloading a PHP image, a MySQL image and a Node image;
[0010] Step S12: using a Dockerfile to compile the PHP image, the MySQL image and the Node image;
[0011] Step S13: using a Docker_compose tool to arrange and deploy a container to run.
[0012] Step S14, after the container runs successfully, the PHP image, the MySQL image, the Node image are packaged into an offline image package, and an offline Docker installation package, a Docker_compose tool package and an offline code package are packaged.
[0013] In the method for building an LNMP environment based on Docker offline provided by the application, in the step S13, the container includes a db container, a php-fpm container, a node container and a nginx container.
[0014] In the method for building an LNMP environment based on Docker offline provided by the application, in the step S13, the starting order of the container is a db container, a php-fpm container, a nginx container and a node container.
[0015] In the method for building an LNMP environment based on Docker offline provided by the application, between the step S13 and the step S1, there is further included verifying whether the service corresponding to the container is successfully run.
[0016] In the method for building an LNMP environment based on Docker offline provided by the application, in the step S12, a required port is set, and a user and a user authority are added.
[0017] In the method for building an LNMP environment based on Docker offline provided by the application, the step S3 includes:
[0018] Step S31, installing the offline Docker installation package and the Docker_compose tool package offline;
[0019] Step S32, importing and decompressing the offline image package and the offline code package;
[0020] Step S33, modifying the authority according to the set user authority;
[0021] Step S34, starting the container;
[0022] Step S35, testing the service corresponding to the container to verify whether the environment is built.
[0023] The technical scheme provided by the present application has the beneficial effects that: the present application provides a method for building LNMP environment based on Docker offline, aiming at the problem that building LNMP environment is limited by network and problems caused by various dependencies or configuration files in the environment when publishing to the test environment in the prior art. The present application uses PHP image, MySQL image and Node image to build installation files including offline image package, offline Docker installation package, Docker_compose tool package and offline code package through Docker, and then copies the installation files to the target server. The LNMP environment can be quickly built in offline state by executing the installation files in the target server, and one-key deployment is realized without extra operation. BRIEF DESCRIPTION OF DRAWINGS
[0024] Figure 1 The method for building LNMP environment based on Docker offline provided by the present application is shown in the flow chart. DETAILED DESCRIPTION
[0025] In order to solve the problem that building LNMP environment is limited by network and problems caused by various dependencies or configuration files in the environment when publishing to the test environment in the prior art, the present application aims to provide a method for building LNMP environment based on Docker offline, which realizes quick building of LNMP environment in offline state. The core idea is to use PHP image, MySQL image and Node image to build installation files including offline image package, offline Docker installation package, Docker_compose tool package and offline code package through Docker, and then copy the installation files to the target server, and execute the installation files in the target server.
[0026] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be described in further detail with reference to the drawings.
[0027] The present application provides a method for building LNMP environment based on Docker offline, which is shown in Figure 1 The method comprises the following steps.
[0028] Step S1, use PHP image, MySQL image and Node image to build installation files through Docker, wherein the installation files include offline image package, offline Docker installation package, Docker_compose tool package and offline code package.
[0029] Specifically, in an embodiment of the present application, first, an official PHP image, a MySQL image, and a Node image are downloaded; then, a Dockerfile is used to build an image, set a required port, add a user and a user authority; after the construction is completed, a Docker_compose tool is used to orchestrate and deploy an image service, which contains four services, i.e., db, php-fpm, node, and nginx, wherein the running of the php-fpm container depends on the db, and the running of the nginx container depends on the php-fpm and the node, so the starting order of the containers is db, php-fpm, nginx, and node; after the containers are started, whether the services are successfully run is verified; after the services are successfully run, each image is packaged into an offline image package, and an offline Docker installation package, a Docker_compose tool package, and an offline code package are packaged. Therefore, step S1 includes:
[0030] Step S11, downloading a PHP image, a MySQL image, and a Node image;
[0031] Step S12, using a Dockerfile to compile the PHP image, the MySQL image, and the Node image;
[0032] Step S13, using a Docker_compose tool to orchestrate and deploy container running;
[0033] Step S14, after the container running is successful, packaging the PHP image, the MySQL image, and the Node image into an offline image package, and packaging an offline Docker installation package, a Docker_compose tool package, and an offline code package.
[0034] Step S2, copying the installation file to a target server;
[0035] Step S3, executing the installation file to verify whether an environment is built.
[0036] Specifically, in an embodiment of the present application, after the packaging is completed, the installation file is copied to a target server and executed. The installation file performs the following operations: 1) offline installation of a docker environment; 2) offline installation of a docker_compose tool; 3) import and decompression of an offline image package; 4) import and decompression of an offline code package; 5) file configuration and modification of an authority; 6) starting of a container; 7) after the container is started, testing of a service to verify whether an environment is built. Therefore, step S3 includes:
[0037] Step S31, offline installation of the offline Docker installation package and the Docker_compose tool package;
[0038] Step S32, importing and decompressing the offline image package and the offline code package;
[0039] Step S33, modifying the permission according to the set user permission;
[0040] Step S34, starting the container;
[0041] Step S35, testing the service corresponding to the container to verify whether the environment is built.
[0042] Through the present application, after the environment is built, the installation package and the image package are copied and the installation file is executed to deploy and build, and the deployment is fast and efficient.
[0043] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or can be completed by programs instructing related hardware, and the programs can be stored in a computer readable storage medium. The above-mentioned control or implementation of the switching function is realized by a controller, and the control unit can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The above-mentioned memory can be a built-in storage device of the terminal, such as a hard disk or a memory. The system of the present application also includes a memory, and the memory can also be an external storage device of the system, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory can also include an internal storage unit of the system and an external storage device, for storing computer programs and other required programs and information. The memory can also be used to temporarily store information that has been output or will be output.
[0044] In summary, the application provides a method for building LNMP environment based on Docker offline, which utilizes PHP image, MySQL image, Node image, builds installation files including offline image package, offline Docker installation package, Docker_compose tool package and offline code package through Docker, and then copies the installation files to a target server; the installation files are executed in the target server to realize quick building of LNMP environment in offline state, one-key deployment and no extra operation.
[0045] The above merely describes preferred embodiments of the application and is not intended to limit the application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the application shall be included in the protection scope of the application.
Claims
1.A method for building an LNMP environment based on Docker offline, characterized in that, The method comprises the following steps: Step S1, using a PHP image, a MySQL image and a Node image, an installation file is built by Docker, the installation file comprising an offline image package, an offline Docker installation package, a Docker_compose tool package and an offline code package; Step S2, copying the installation file to a target server; Step S3, executing the installation file to verify whether the environment is built; The step S1 comprises: Step S11, downloading a PHP image, a MySQL image and a Node image; Step S12, compiling the PHP image, the MySQL image and the Node image by using a Dockerfile; Step S13, using a Docker_compose tool to arrange and deploy a container to run; Step S14, after the container runs successfully, the PHP image, the MySQL image and the Node image are packaged into an offline image package, and an offline Docker installation package, a Docker_compose tool package and an offline code package are packaged; In the step S13, the container comprises a db container, a php-fpm container, a node container and an nginx container; In the step S13, the starting sequence of the container is a db container, a php-fpm container, an nginx container and a node container; Between the step S13 and the step S1, it further comprises verifying whether the service corresponding to the container runs successfully; In the step S12, a required port is set, a user and a user authority are added; The step S3 comprises: Step S31, offline installing the offline Docker installation package and the Docker_compose tool package; Step S32, importing and decompressing the offline image package and the offline code package; Step S33, modifying an authority according to a set user authority; Step S34, starting the container; Step S35, testing the service corresponding to the container to verify whether the environment is built.
Citation Information
Patent Citations
Method and device for service deployment, readable medium, and storage controller
CN107885551A
Construction method and device of website service system
CN112965727A