Ubuntu builds a LNMP+REDIS development environment based on Docker
Server environment: Ubuntu 14.04
1. Install Docker
1.1 Execute the UPDATE command, and the server synchronization package, the implementation of Apt-get install * Can download the latest software.
1.2 Installing Docker and creating soft links
1.3 Enable Docker Service
2. Get the mirrors needed to build the environment
2.1 MySQL Mirror
2.2 Redis Mirroring
2.3 NGINX-PHP-FPM Mirroring
2.4 View the downloaded mirrors
For Docker beginners, you can use the existing mirrors, the current download image of the channel is mainly Docker official public warehouses Docker Hub (https://hub.docker.com) and the domestic daocloud (https:// Dashboard.daocloud.io), the difference is that foreign resources are more, but the download speed is very slow, domestic resources are less, but the download speed is very fast. Of course, the ability of a better technician, you can build the required mirror, and can upload to the above two sites shared out.
3. Using mirrors to generate the corresponding container
3.1 Build MySQL Container
3.1.1--name is the container name, Mysql_test is the custom name;
3.1.2-p exposed ports, mapping ports (can map multiple ports), external ports: container internal ports;
3.1.3-E Set any environment variable (inside container)
Mysql_root_password=root This means setting the database password to ROOT;
3.1.4 mysql:5.6 Mirror Name: Version
3.2 Generating Redis containers
3.2.1-p6379:6379 mapping port, External port: Container inside Port
3.2.2 Redis Mirror version
3.3 Generating NGINX-PHP-FPM containers
3.3.1--namelnmp_test is the name of the container;
3.3.2-p exposed port, mapping port (can map multiple ports) External port: container internal port;
-P 88:80 External Port 88: container Internal Port 80;
3.3.3-d: Background mode runs, if not, run in front (the current container shuts down automatically after the current process closes)
3.3.4 richarvey/nginx-php-fpm Current mirror name: version
3.3.5--link: Container Internal communication container name: internal alias (internal use)
--link mysql:db access to database MySQL container when used directly with DB
PHP access to local MySQL using localhost, the container can be used inside the DB
3.3.6-v: Volume, external directory virtual to container directory external directory: Inside container directory
-v/home/lanmps/www:/www/wwwroot
/home/lanmps/www external directory, my project directory
/www/wwwroot Container Internal Directory
3.4. View the containers that have been built and start the container
Problems that may arise:
1. Mirror download slow or fail, as shown in figure:
The main reason: Resources have been canceled, slow speed;
Solution: Priority to find domestic mirror resources, get mirror failure to find resources or do the required mirror resources themselves;
1. Modify the Mount directory file, can not sync to the container environment;
Reason: The site directory path in the Nginx configuration file in the container is inconsistent with the path I have mounted;
Workaround: Enter the container environment and modify the Nginx configuration file.
Test whether to build success:
You can successfully access the built environment and the database can be successfully connected.
Thank you for reading, I hope to help you, thank you for your support for this site!