| |
| cd /etc/yum.repos.d/ |
| mkdir -p /centos.repo.bak |
| mv * /centos.repo.bak/ |
| |
| sudo curl -o /etc/yum.repos.d/docker-ce.repo |
| https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo |
| curl -o Centos-Base-aliyun.repo https://mirrors.aliyun.com/repo/Centos-7.repo |
| |
| curl -o epel-7-aliyun.repo https://mirrors.aliyun.com/repo/epel-7.repo |
| |
| sudo yum clean all |
| sudo yum makecache |
| |
| systemctl stop firewalld && systemctl disable firewalld && sed -i "s?enfofcoing=?disabled?" /etc/selinux/config && setenforce 0 && systemctl status firewalld |
| |
| |
| 配置网卡dns 114 114 114 114 |
| |
| systemctl restart network |
| |
| |
| yum -y update && yum install –y ntpdate && ntpdate ntp1.aliyun.com |
| |
| |
| yum remove docker docker-common docker-selinux docker-engine |
| |
| |
| yum install -y yum-utils device-mapper-persistent-data lvm2 |
| |
| yum install docker-ce docker-ce-cli containerd.io -y |
| |
| systemctl start docker && systemclt enble docker && docker status docker |
| echo "查看进程" && ps -ef | grep docker && docker version |
| |
| |
| sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose |
| |
| docker-compose -v |
| |
| vi /etc/docker/daemon.json |
| { |
| "registry-mirrors": [ |
| "https://c7s5k5vw.mirror.aliyuncs.com", |
| "https://dockerpull.org", |
| "https://docker.unsee.tech/", |
| "https://docker.1panel.live/", |
| "https://docker.udayun.com/", |
| "https://docker.nastool.de/"], |
| "dns": ["8.8.8.8","114.114.114.114","223.5.5.5"] |
| } |
| ~ |
| |
| systemctl daemon-reload && systemctl restart docker && systemctl status docker |
| |
| |
| docker run -dit -p 80:80 nginx:latest |
| |
| |
| mkdir /root/lnmp-wordpress && cd /root/lnmp-wordpress && vi docker-compose.yml |
*2. 安装 Docker Compose*
Compose 版本 |
Docker 版本 |
3.8 |
19.03.0+ |
3.7 |
18.06.0+ |
3.6 |
18.02.0+ |
3.5 |
17.12.0+ |
3.4 |
17.09.0+ |
3.3 |
17.06.0+ |
3.2 |
17.04.0+ |
3.1 |
1.13.1+ |
3.0 |
1.13.0+ |
2.4 |
17.12.0+ |
2.3 |
17.06.0+ |
2.2 |
1.13.0+ |
2.1 |
1.12.0+ |
2.0 |
1.10.0+ |
| yum -y insatll docker-compose && docker-compose --version |
| |
| mkdir /root/lnmp-wordpress && cd /root/lnmp-wordpress && vi docker-compose.yml |
| version: '3' |
| services: |
| db: |
| image: mysql:8.0 |
| container_name: mysql-wordpress |
| restart: always |
| environment: |
| MYSQL_ROOT_PASSWORD: rootpassword |
| MYSQL_DATABASE: wordpress |
| MYSQL_USER: wordpressuser |
| MYSQL_PASSWORD: wordpresspassword |
| volumes: |
| - mysql-data:/var/lib/mysql |
| ports: |
| - "3306:3306" |
| |
| wordpress: |
| depends_on: |
| - db |
| image: wordpress:latest |
| container_name: wordpress |
| restart: always |
| ports: |
| - "8080:80" |
| environment: |
| WORDPRESS_DB_HOST: db:3306 |
| WORDPRESS_DB_USER: wordpressuser |
| WORDPRESS_DB_PASSWORD: wordpresspassword |
| WORDPRESS_DB_NAME: wordpress |
| volumes: |
| - wordpress-data:/var/www/html |
| |
| nginx: |
| image: nginx:latest |
| container_name: nginx |
| restart: always |
| ports: |
| - "80:80" |
| volumes: |
| - wordpress-data:/var/www/html |
| - ./nginx.conf:/etc/nginx/conf.d/default.conf |
| depends_on: |
| - wordpress |
| |
| volumes: |
| mysql-data: |
| wordpress-data: |
| |
| |
| |
| cd /root/lnmp-wordpressvi nginx.conf |
| server { |
| listen 80; |
| server_name _; |
| root /var/www/html; |
| index index.php index.html index.htm; |
| |
| location / { |
| try_files $uri $uri/ /index.php?$query_string; |
| } |
| |
| location ~ .php$ { |
| fastcgi_pass wordpress:9000; |
| fastcgi_index index.php; |
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| include fastcgi_params; |
| } |
| |
| } |
| |
| |
| cd /root/lnmp-wordpress |
| docker-compose up -d |
| docker images |
| docker run 镜像名 |
| http://192.168.33.10:8080 |
| |
| |
| docker stop $(docker ps -q) |
| docker rm -f $(docker ps -aq) |
| docker volume rm lnmp-wordpress_mysql-data lnmp-wordpress_wordpress-data |
| docker ps -a |
| docker volume ls |