shell脚本模板 — 使用Dokcer构建WordPress

文章目录

运行

[root@vultrguest ~] ------- INSTALL WORDPRESS WITH ONE CLICK Config Firewall Enable SELinux Set Hostname as simwor Installing Docker Installed: containerd.io-1.3.7-3.1.el8.x86_64 docker-ce-3:19.03.13-3.el8.x86_64 docker-ce-cli-1:19.03.13-3.el8.x86_64 libcgroup-0.41-19.el8.x86_64 Installing Docker-Compose % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 651 100 651 0 0 20343 0 --:--:-- --:--:-- --:--:-- 20343 100 11.6M 100 11.6M 0 0 4790k 0 0:00:02 0:00:02 --:--:-- 5682k Pull Docker Images latest: Pulling from library/wordpress latest: Pulling from library/mysql Init WordPress Creating network "compose_default" with the default driver Creating simwor ... done Creating simwordb ... done WordPress seems done, its docker-base-dir locates at /opt/docker/simwor Now, you can access your website on your browser. [root@simwor ~] /opt/docker/simwor/ ├── compose ├── mysql └── wordpress 3 directories, 0 files [root@simwor ~] 

访问

在这里插入图片描述

脚本

#!/bin/sh  echo "------- INSTALL WORDPRESS WITH ONE CLICK"  hostname=simwor  domestic=0   echo echo "Config Firewall" systemctl start firewalld systemctl enable firewalld firewall-cmd --zone=public --permanent --add-masquerade firewall-cmd --permanent --add-service=http firewall-cmd --reload  echo echo "Enable SELinux" if [ `getenforce` == "Permissive" ]; then setenforce 1 fi sed -i 's/^SELINUX=disabled$/SELINUX=enforcing/' /etc/selinux/config  echo echo "Set Hostname as $hostname" hostnamectl set-hostname $hostname   echo echo "Installing Docker" curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo if [ $domestic -eq 1 ]; then sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo fi dnf install -y --allowerasing docker-ce  echo echo "Installing Docker-Compose" if [ ! -f /usr/local/bin/docker-compose ] then curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose fi   if [ ! -f /etc/docker/daemon.json ] && [ $domestic -eq 1 ] then cat << EOF > /etc/docker/daemon.json { "registry-mirrors": ["https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com"] } EOF fi  echo echo "Pull Docker Images" systemctl enable docker.service systemctl start docker.service docker pull wordpress docker pull mysql  echo echo "Init WordPress" sitename=simwor sitedb=`echo $sitename`db mkdir -p /opt/docker/$sitename/compose cd /opt/docker/$sitename/compose cat << EOF > docker-compose.yml version: "3.8" services: $sitename: image: wordpress restart: always container_name: $sitename ports: - 80:80 environment: WORDPRESS_DB_HOST: $sitedb WORDPRESS_DB_USER: $sitename WORDPRESS_DB_NAME: $sitename WORDPRESS_DB_PASSWORD: abcd1234.. volumes: - /opt/docker/$sitename/wordpress:/var/www/html $sitedb: image: mysql restart: always container_name: $sitedb environment: MYSQL_ROOT_PASSWORD: abcd1234.. MYSQL_DATABASE: $sitename MYSQL_USER: $sitename MYSQL_PASSWORD: abcd1234.. volumes: - /opt/docker/$sitename/mysql:/var/lib/mysql EOF docker-compose up -d cd echo echo "Wordpress seems done, its docker-base-dir locates at /opt/docker/$sitename" echo "Now, you can access your website on your browser." echo 

原文链接:https://blog.csdn.net/weixin_42480750/article/details/109524754?ops_request_misc=&request_id=7cb96661014841d0b61a25057c1c090a&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-2-109524754-null-null.268%5Ev1%5Econtrol&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享