In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
How to use Docker to build LNMP website platform? In order to let you know more about Docker and build the LNMP website platform, the editor summarizes the following content for you. Let's read on.
one。 Demonstration environment
Host operating system: CentOS Linux release 7.5
Virtual machine tools: VMware ®Workstation 10
Application Container engine: Docker version 19.03.7
two。 Actual combat task
Build LNMP website platform through Docker environment
III. Operation steps
1. Create a custom network
[root@docker /] # docker network create lnmp
B30f1b9528faee766da780efb2d2c07c2d8072a5ca5fb4ae5a2d0315596956f4
[root@docker /] # docker network ls
NETWORK ID NAME DRIVER SCOPE
6c43b3bccf7d bridge bridge local
4072f40421c1 host host local
B30f1b9528fa lnmp bridge local
A7192659cbd7 none null local
two。 Create a Mysql database container
# create a mysql "target=" _ blank "href=" http://undefined">mysql container. If it does not exist locally, the latest version 8.0 will be downloaded from the Internet.
[root@docker /] #
Docker run-itd-- name lnmp_mysql-- net lnmp-p 3306 name lnmp_mysql-- mount src=mysql-vol,dst=/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=sky9890 mysql-- character-set-server=utf8
Latest: Pulling from library/mysql
..
# the latest mysql8.0 version image is downloaded above
[root@docker sky9890] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Mysql latest 9b51d9275906 2 days ago 547MB
# View the running container
[root@docker wordpress] # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Ec5683f08179 mysql "docker-entrypoint.s..." 53 minutes ago Up 53 minutes 0.0.0.0 3306/tcp 3306-> 33060/tcp lnmp_mysql
# View lnmp_mysql container logs
[root@docker /] # docker logs lnmp_mysql
...
# View lnmp_mysql Container process
[root@docker wordpress] # docker top lnmp_mysql
UID PID PPID C STIME TTY TIME CMD
Polkitd 7594 7578 1 10:20 pts/0 00:00:40 mysqld-character-set-server=utf8
Root 7942 7578 0 10:23 pts/1 00:00:00 / bin/bash
Root 8132 7942 0 10:27 pts/1 00:00:00 mysql-uroot-p
# create a mysql-vol volume while creating a container
[root@docker wordpress] # docker volume ls
DRIVER VOLUME NAME
Local mysql-vol
3. Create the required database
[root@docker /] # docker exec lnmp_mysql sh-c 'exec mysql-uroot-p "$MYSQL_ROOT_PASSWORD"-e "create database wp"'
# execute the lnmp_mysql container to view the database required for the created wordpress.
[root@docker sky9890] # docker exec-it lnmp_mysql / bin/bash
Root@ec5683f08179:/#
Root@ec5683f08179:/# mysql-uroot-p
Mysql > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | sys |
| | wp |
+-+
5 rows in set (0.00 sec)
4. Create a Nginx-php environment container
# create a nginx-php-fpm container. If it does not exist locally, temporarily download the latest version from the Internet
# the class that mounts the host is bind mound
# Host directory / html/wwwroot
[root@docker sky9890] #
Docker run-itd-- name lnmp_web-- net lnmp-p 8080 net lnmp 80-- mount type=bind,src=/html/wwwroot
Dst=/var/www/html richarvey/nginx-php-fpm
Unable to find image 'richarvey/nginx-php-fpm:latest' locally
Latest: Pulling from richarvey/nginx-php-fpm
C9b1b535fdd9: Already exists
...
6d7274bf00fecf8e4fd0f998005f7640ec4e3e0c0f91cc6cce92bac0fa037a2e
# the nginx-php-fpm image is downloaded above
[root@docker sky9890] # docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Mysql latest 9b51d9275906 2 days ago 547MB
Richarvey/nginx-php-fpm latest f9c09b816ede 4 weeks ago 331MB
# View the running lnmp_mysql container
[root@docker wordpress] # docker ps process
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Ec5683f08179 mysql "docker-entrypoint.s..." About an hour ago Up About an hour 0.0.0.0 33060/tcp lnmp_mysql 3306-> 3306/tcp
6d7274bf00fe richarvey/nginx-php-fpm "docker-php-entrypoi..." 2 hours ago Up 2 hours 443/tcp, 9000/tcp, 0.0.0.0 9000/tcp 8080-> 80/tcp lnmp_web
5. Take wordpress blog as the test case
[root@docker sky9890] # wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz
-- 2020-03-06 09-14-14-https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz
Parsing host cn.wordpress.org (cn.wordpress.org)... 198.143.164.252
Connecting cn.wordpress.org (cn.wordpress.org) | 198.143.164.252 |: 443. Connected.
A HTTP request has been issued and is waiting for a response. 429 Too Many Requests
2020-03-06 09:49:05 error 429:Too Many Requests.
# the above indicates that there is a problem with the official website of wordpress
# temporarily change to another address to download:
[root@docker tools] # wget https://cn.wp.xz.cn/latest-zh_CN.tar.gz
[root@docker tools] # tar zxvf wordpress-5.3.2-zh_CN.tar.gz-C / html/wwwroot/
# Directory on the host:
[root@docker tools] # ls / html/wwwroot/
Index.html test.html tt wordpress
6. Browser access installation and test
Http://192.168.153.141:8080/wordpress
# the error in the following figure will be reported when executing above, because no database host is specified.
# the correct database host (lnmp_msyql container) is specified below
The installation cannot be performed above because the installation configuration file does not have write permission.
..
-rw-r--r-- 1 1006 1006 2746 March 7 10:36 wp-config-sample.php
[root@docker wordpress] # cp wp-config-sample.php wp-config.php
[root@docker wordpress] # chmod 777 wp-config.php
# next, continue to install through the browser. It is not recommended to copy the content to the wp-cofnig.php file. As long as the configuration file has write permission, the configuration file is automatically rewritten during installation.
On how to use Docker to build LNMP website platform to share here, of course, not only the above and everyone analysis methods, but the editor can ensure its accuracy is absolutely no problem. I hope that the above content can have a certain reference value for everyone, and can be put into practice. If you like this article, you might as well share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.