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
We know that the properties of the select tag in e...
1. Problem There is a table as shown below, we ne...
Basic three-column layout .container{ display: fl...
This article uses an example to illustrate the us...
[LeetCode] 178.Rank Scores Write a SQL query to r...
Concept of SFTP sftp is the abbreviation of Secur...
Page domain relationship: The main page a.html bel...
Table of contents Preface 1. Binary Tree 1.1. Tra...
Table of contents render.js part create-context.j...
Table of contents 1. Install and import 2. Define...
Preface Starting from React 16, the concept of Er...
Preface Vue provides a wealth of built-in directi...
The following is a bar chart using Flex layout: H...
Adding the attribute selected = "selected&quo...
1. Install the Linux system on the virtual machin...