LNMP is a dynamic website server architecture built by combining Nginx, Mariadb and PHP under Linux system. Next, we use Docker to create a distributed lnmp image. 1. Docker distributed lnmp image production1. Run Nginx, MySQL, and PHP containers#Turn off the firewall and core protection systemctl disable firewalld systemctl stop firewalld setenforce 0 # Check whether ports 3306, 80, and 9000 are occupied ss -natp | grep 3306 ss -natp | grep 80 ss -natp | grep 9000 #Create a custom network docker network create -d bridge --subnet 172.168.184.0/24 --gateway 172.168.184.1 lnmp #Run the Nginx container docker run -itd --name nginx --network lnmp -p 80:80 --ip 172.168.184.10 nginx:1.12.0 #Run the MySQL container docker run -itd --name mysql --network lnmp -p 3306:3306 --ip 172.168.184.20 -e MYSQL_ROOT_PASSWORD=010230 mysql:5.7 #Run the PHP container docker run -itd --name phpfpm --network lnmp -p 9000:9000 --ip 172.168.184.30 php:7.1-fpm 2. Modify Nginx configuration file and PHP filedocker exec -it nginx /bin/bash echo -e "server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htmi index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 172.168.184.30:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; include fastcgi_params; } }" > /etc/nginx/conf.d/default.conf nginx -s reload docker exec -it phpfpm /bin/bash mkdir -p /usr/share/nginx/html echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php 4. Conduct testingEnter localhost/index.php in the virtual machine Enter 192.168.184.70/index.php on this machine (my virtual machine address is 192.168.184.70) The above is the details of using docker to create a distributed lnmp image. For more information about docker distributed lnmp images, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: What does href=# mean in a link?
>>: Detailed tutorial on installation and configuration of compressed version of MySQL database
js realizes the special effect of clicking and dr...
1. Download MySQL Community Server 5.6.35 Downloa...
The default table name is base_data and the json ...
Table of contents 1. Basic types 2. Object Type 2...
1 Keep the rpm package downloaded when yum instal...
Concurrency Functions time for i in `grep server ...
Table of contents 1. Merge interface 1.1 Non-func...
Table of contents First look at the effect: accom...
1. Purpose Through this article, everyone can und...
Table of contents Example Code Rendering Code Ana...
Today I will share with you a good-looking counte...
After I analyzed the Taobao details page last time...
This article shares the detailed steps of install...
<br /> The website access speed can directly...
Table of contents Overview 1. Define store.js 2. ...