Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build lnmp website structure quickly by docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "docker how to quickly build lnmp website architecture", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "docker how to quickly build lnmp website architecture" this article bar.

1.centos7 Install docker

Install dependency packages

yum install -y yum-utils device-mapper-persistent-data lvm2

Add Docker Package Source

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Or use Alibaba Cloud's source wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Install Docker CE

yum install docker-ce -y

Binary package address download.docker.com/linux/static/stable/x86_64/

start

systemctl start docker

startup

systemctl enable docker

View Docker information

docker info

Configure docker accelerator

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh|sh -s http://bc437cce.m.daocloud.io

2. Custom network, commonly used in production environment, containers created later are added to lnmp network

docker network create lnmp

3. Creating a mysql container

mysql5.7 version is used here, and the parameter--restart always is added to ensure that the container can start automatically when the host is started.

docker run -itd --restart always --name lnmp_mysql --net lnmp -p 3306:3306 --mount src=mysql-vol,dst=/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_DATABASE=wordpress mysql:5.7 --character-set-server=utf8

The mysql-vol volume is automatically created.

[root@localhost volumes]# pwd

/var/lib/docker/volumes

[root@localhost volumes]# docker volume ls

DRIVER VOLUME NAME

local mysql-vol

local rancher-agent-state

local rancher-cni

local rancher-cni-driver

[root@localhost volumes]# docker volume inspect mysql-vol

[

{

"CreatedAt": "2019-08-18T11:52:35+08:00",

"Driver": "local",

"Labels": null,

"Mountpoint": "/var/lib/docker/volumes/mysql-vol/_data",

"Name": "mysql-vol",

"Options": null,

"Scope": "local"

}

]

Create a volume for example docker volume create nginx-vol

After the container is created, the database wordpress is created

Enter mysql container, docker exec -it lnmp_mysql /bin/bash

Enter database mysql -uroot -p123456

Create a regular user

grant all on wordpress.* to wordpress@'%' identified by '123456';

flush privileges;

mysql> select user,host from mysql.user;

+---------------+-----------+

| user | host |

+---------------+-----------+

| root | % |

| wordpress | % |

| mysql.session | localhost |

| mysql.sys | localhost |

| root | localhost |

+---------------+-----------+

5 rows in set (0.01 sec)

mysql>

docker exec lnmp_mysql bash -c 'exec mysql -uroot -p123456 -e "grant all on wordpress.* to wordpress@'%' identified by '123456';"'

4. Create a web environment (nginx+php), where the images used include nginx and php-fpm

docker run -itd --restart always --name lnmp_web --net lnmp -p 88:80 --mount type=bind,src=/lnmp/web,dst=/var/www/html richarvey/nginx-php-fpm

Create the/lnmp/web directory locally and mount the directory to the container for data persistence.

5. Wordpress Blog

Download wordpress from wordpress official website https://cn.wordpress.org/and extract it to/lnmp/web

Visit http://192.168.56.135:88/wordpress, and then you can configure and install wordpress

The above is "docker how to quickly build lnmp website architecture" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report