k8s 部署wordpress

    技术2022-07-11  71

    制作nginx镜像

    docker pull centos:7.6.1810 docker run -it --name nginx centos:7.6.1810 /bin/bash yum install epel-release yum install nginx net-tools -y

    vi /etc/nginx/nginx.conf

    user root; daemon off; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /data/logs/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; }

    vi /etc/nginx/conf.d/localhost.conf

    server { listen 80; server_name wordpress.tencent.com localhost; error_log /data/logs/nginx/wordpress.tencent.com_error.log error; root /data/www/wordpress; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass unix:/dev/shm/php-fpm.sock; } }

    创建目录

    mkdir /data/logs/nginx -p

    提交镜像

    docker commit b8e1e0ea8c1d mynginx:v1

    制作php镜像

    docker run -it --name php centos:7.6.1810 /bin/bash yum install epel-release -y rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum install php70w php70w-fpm php70w-cli php70w-common php70w-devel php70w-gd php70w-pdo php70w-mysql php70w-mbstring php70w-bcmath php70w-xml php70w-peclredis php70w-process php70w-intl php70w-xmlrpc php70w-soap php70w-ldap php70w- opcache -y

    vi /etc/php-fpm.conf

    error_log = /data/logs/php/error.log daemonize = no

    vi /etc/php-fpm.d/www.conf

    user = root group = root listen = /dev/shm/php-fpm.sock listen.owner = root listen.group = root slowlog = /data/logs/php/www-slow.log php_admin_value[error_log] = /data/logs/php/www-error.log

    创建目录

    mkdir /data/logs/php -p

    提交镜像

    docker commit 3350eef95741 myphp:v1

    代码

    -rw-r--r-- 1 root root 151 Jul 1 22:29 Dockerfile -rw-r--r-- 1 root root 405 Jul 1 22:09 index.php -rw-r--r-- 1 root root 19915 Jul 1 22:09 license.txt -rw-r--r-- 1 root root 7278 Jul 1 22:09 readme.html -rw-r--r-- 1 root root 6912 Jul 1 22:09 wp-activate.php drwxr-xr-x 9 root root 4096 Jul 1 22:09 wp-admin -rw-r--r-- 1 root root 351 Jul 1 22:09 wp-blog-header.php -rw-r--r-- 1 root root 2332 Jul 1 22:09 wp-comments-post.php -rw-r--r-- 1 root root 2913 Jul 1 22:09 wp-config-sample.php drwxr-xr-x 4 root root 52 Jul 1 22:09 wp-content -rw-r--r-- 1 root root 3940 Jul 1 22:09 wp-cron.php drwxr-xr-x 21 root root 8192 Jul 1 22:09 wp-includes -rw-r--r-- 1 root root 2496 Jul 1 22:09 wp-links-opml.php -rw-r--r-- 1 root root 3300 Jul 1 22:09 wp-load.php -rw-r--r-- 1 root root 47874 Jul 1 22:09 wp-login.php -rw-r--r-- 1 root root 8509 Jul 1 22:09 wp-mail.php -rw-r--r-- 1 root root 19396 Jul 1 22:09 wp-settings.php -rw-r--r-- 1 root root 31111 Jul 1 22:09 wp-signup.php -rw-r--r-- 1 root root 4755 Jul 1 22:09 wp-trackback.php -rw-r--r-- 1 root root 3133 Jul 1 22:09 xmlrpc.php

    nginx-wordpress镜像制作

    cat Dockerfile

    FROM mynginx:v1 MAINTAINER 1226032602 1226032602@qq.com RUN mkdir -p /data/www/wordpress ADD . /data/www/wordpress EXPOSE 80 ENTRYPOINT ["/usr/sbin/nginx"] docker build . -t nginx-wordpress:v1 docker tag nginx-wordpress:v1 harbor.od.com/public/nginx-wordpress:v1 docker push harbor.od.com/public/nginx-wordpress:v1

    nfs

    vim /etc/exports

    /data/nfs-volume 10.4.7.0/24(rw,no_root_squash)

    php-wordpress镜像制作

    cat Dockerfile

    FROM myphp:v1 MAINTAINER 1226032602 1226032602@qq.com RUN mkdir -p /data/www/wordpress ADD . /data/www/wordpress ENTRYPOINT ["/usr/sbin/php-fpm","-R"] docker build . -t php-wordpress:v1 docker tag php-wordpress:v1 harbor.od.com/public/php-wordpress:v1 docker push harbor.od.com/public/php-wordpress:v1

    configMap

    vi nginx-wordpress-configmap.yaml

    apiVersion: v1 data: localhost.conf: | server { listen 80; server_name wordpress.tencent.com localhost; error_log /data/logs/nginx/wordpress.tencent.com_error.log error; root /data/www/wordpress; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass unix:/dev/shm/php-fpm.sock; } } kind: ConfigMap metadata: name: nginxconf namespace: default

    vi wp-config.yaml

    apiVersion: v1 data: wp-config.php: | <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'wordpress' ); /** MySQL database password */ define( 'DB_PASSWORD', '123456' ); /** MySQL hostname */ define( 'DB_HOST', '10.4.7.11' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8mb4' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); /**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. * * @since 2.6.0 */ define( 'AUTH_KEY', '!j{}>)e}_k9M=D;lsoKR2o:FrvZ (ML+CK;<18R-%9IIU#r%/NdOz.Y.B%SChnO$' ); define( 'SECURE_AUTH_KEY', 'Kr8-n 9OEy`RF4j`qoQaVS3%!/asg*-1VHK>x!WmO;P~w{2mZw5C!RS7x}r9W}se' ); define( 'LOGGED_IN_KEY', 'Qe<*nE3kW_9@KqZ]F&~mz6B]{A<K48CWmk GWv*(]H]</pDxhQ+c!UrDQg]Qw0<D' ); define( 'NONCE_KEY', 'n{bW`%=sogNl:~|_I:K69m#w075Jwc$=k?_=k2=!{|Gu%-,g]}i*:N;Co5_75?oo' ); define( 'AUTH_SALT', '%{#> oDDT#D???bD-;,|-3Qbv;:sUi<9h 1@,3oq25c:b9vKnH^&l1l5#?373_XV' ); define( 'SECURE_AUTH_SALT', 'eOpRcCgvKl0gRol]cUj7rZklTI?z(>5+$rU5}1?6!itK)8 t-_|FF:[#S{@_xeo+' ); define( 'LOGGED_IN_SALT', 'x40,tVmi~R}j7jqqM;Wy72nRMTc5<t[If`5I8{=d(yqi:rF
    转载请注明原文地址:https://ipadbbs.8miu.com/read-19034.html
    最新回复(0)