一个主机上的多个wordpress

时间:2017-12-28 00:18:50

标签: mysql wordpress nginx

我正在尝试在主机上部署多个WordPress。我使用nginx将连接分发到好的子域。

我成功部署了第一个带有WordPress和MySQL服务器的容器。使用此脚本:



version: '2'

services:
   db3:
     image: mysql:5.7
     volumes:
       - db_wp_lmt_data:/var/lib/mysql
     restart: always
     ports:
       - 3308:3306
       - 3308
     environment:
       MYSQL_ROOT_PASSWORD: FFFF
       MYSQL_DATABASE: DDDD
       MYSQL_USER: XXX
       MYSQL_PASSWORD: YYYY
   wordpress:
     depends_on:
       - db3
     image: wordpress:latest
     ports:
       - "8003:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db3:3306
       WORDPRESS_DB_USER: XXX
       WORDPRESS_DB_PASSWORD: YYYY
       VIRTUAL_HOST: ZZZZZ
     volumes:
       - wp_lmt_data:/var/www/html
volumes:
    db_wp_lmt_data:
    wp_lmt_data:
networks:
  default:
    external:
      name: nginxproxy_default




然而,当我添加第二个具有相同脚本(在将端口从8003更改为8004和3308到3009之后)时,我遇到了一些麻烦。可以从外部访问mysql服务器,但wordpress不起作用。当我从主持人" curl -k localhost:8004"它没有返回任何内容,而另一个wordpress返回主页内容。

我试图理解为什么它不起作用,并解决它。但现在我不知道如何解决它。

此外,我在附加模式下启动容器,一切看起来都很好:



db3_1        | 2017-12-27T23:50:45.558909Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db3_1        | 2017-12-27T23:50:45.597390Z 0 [Note] mysqld (mysqld 5.7.20) starting as process 1 ...
db3_1        | 2017-12-27T23:50:45.612731Z 0 [Note] InnoDB: PUNCH HOLE support available
db3_1        | 2017-12-27T23:50:45.612804Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db3_1        | 2017-12-27T23:50:45.612812Z 0 [Note] InnoDB: Uses event mutexes
db3_1        | 2017-12-27T23:50:45.612818Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db3_1        | 2017-12-27T23:50:45.612824Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
db3_1        | 2017-12-27T23:50:45.612830Z 0 [Note] InnoDB: Using Linux native AIO
db3_1        | 2017-12-27T23:50:45.632121Z 0 [Note] InnoDB: Number of pools: 1
db3_1        | 2017-12-27T23:50:45.632384Z 0 [Note] InnoDB: Using CPU crc32 instructions
db3_1        | 2017-12-27T23:50:45.657365Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db3_1        | 2017-12-27T23:50:45.722114Z 0 [Note] InnoDB: Completed initialization of buffer pool
db3_1        | 2017-12-27T23:50:45.735602Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db3_1        | 2017-12-27T23:50:45.759510Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db3_1        | 2017-12-27T23:50:45.798036Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db3_1        | 2017-12-27T23:50:45.798748Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db3_1        | 2017-12-27T23:50:45.873142Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db3_1        | 2017-12-27T23:50:45.874746Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db3_1        | 2017-12-27T23:50:45.874819Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db3_1        | 2017-12-27T23:50:45.876036Z 0 [Note] InnoDB: Waiting for purge to start
db3_1        | 2017-12-27T23:50:45.926379Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 12156537
db3_1        | 2017-12-27T23:50:45.928422Z 0 [Note] Plugin 'FEDERATED' is disabled.
db3_1        | 2017-12-27T23:50:45.932793Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db3_1        | 2017-12-27T23:50:45.968083Z 0 [Note] InnoDB: Buffer pool(s) load completed at 171227 23:50:45
db3_1        | 2017-12-27T23:50:45.969521Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db3_1        | 2017-12-27T23:50:45.973412Z 0 [Warning] CA certificate ca.pem is self signed.
db3_1        | 2017-12-27T23:50:45.976434Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db3_1        | 2017-12-27T23:50:45.981110Z 0 [Note] IPv6 is available.
db3_1        | 2017-12-27T23:50:45.981787Z 0 [Note]   - '::' resolves to '::';
db3_1        | 2017-12-27T23:50:45.982192Z 0 [Note] Server socket created on IP: '::'.
db3_1        | 2017-12-27T23:50:45.989810Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.990490Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.990563Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.990660Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.990738Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.990805Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.996112Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:45.996739Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db3_1        | 2017-12-27T23:50:46.021269Z 0 [Note] Event Scheduler: Loaded 0 events
db3_1        | 2017-12-27T23:50:46.022382Z 0 [Note] mysqld: ready for connections.
db3_1        | Version: '5.7.20'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
db3_1        | 2017-12-27T23:50:46.022476Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
db3_1        | 2017-12-27T23:50:46.022543Z 0 [Note] Beginning of list of non-natively partitioned tables
db3_1        | 2017-12-27T23:50:46.069871Z 0 [Note] End of list of non-natively partitioned tables
wordpress_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.6. Set the 'ServerName' directive globally to suppress this message
wordpress_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.6. Set the 'ServerName' directive globally to suppress this message
wordpress_1  | [Wed Dec 27 23:50:46.370813 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.0 configured -- resuming normal operations
wordpress_1  | [Wed Dec 27 23:50:46.374367 2017] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'




感谢您的关注。

1 个答案:

答案 0 :(得分:0)

我终于找到了一种方法来做我想做的事。我删除了我的docker-compose.yml并从头开始。

我改用了这个脚本:

version: '2'

services:
    wordpress:
        image: wordpress
        links:
         - mariadb:mysql
        environment:
         - WORDPRESS_DB_PASSWORD=XXX
         - VIRTUAL_HOST= YYY
        ports:
         - "10001:80"
         - 10001
        expose:
         - 10001
        volumes:
         - mywordpressvolume:/var/www/html

    mariadb:
        image: mariadb
        environment:
         - MYSQL_ROOT_PASSWORD=XX
         - MYSQL_DATABASE=wordpress
        volumes:
         - mydbvolume:/var/lib/mysql

volumes:
    mywordpressvolume:
    mydbvolume:
    
networks:
  default:
    external:
      name: nginxproxy_default

这给了我一个有效的WordPress。我仍然困惑为什么WordPress有这种行为。也许WordPress无法访问数据库是有原因的,我想知道使用链接服务名称是否是一个好习惯。然后,我使用了命令

  

docker exec mycontainername env | grep“VIRTU”

检查我的容器使用的所有VIRTUAL_HOST变量。最后,它结束了。