簡體   English   中英

AWS EC2 上的 WordPress 與 Docker-Compose 和 AWS RDS MySQL 數據庫

[英]WordPress on AWS EC2 with Docker-Compose and AWS RDS MySQL Database

I'm trying to setup a WordPress website on an AWS EC2 Ubuntu 18.04 server, in a Docker container using Docker-Compose, and using an AWS RDS MySQL database instead of having the database in another container on the server.

麻煩的是,我似乎無法從 web 瀏覽器連接,以調出“著名的”初始 WordPress 設置。

我在我的 EC2 安全組上啟用了入站端口 82,到所有 IP 地址(例如 0.0.0.0)。

這是我的 docker-compose.yml 文件:

version: '3.7'
services:
  wordpress:
    # Name of the container this service creates. Otherwise it's prefixed with the git repo name
    container_name: wordpress
    restart: unless-stopped
    image: wordpress:5.4.1-php7.2-fpm-alpine
    env_file: .env
    ports:
      - "0.0.0.0:82:9000" # for bypassing Nginx and testing on port 82
    expose: 
      - 9000 # Default for the Alpine image
    volumes:
      - wordpress:/var/www/html

volumes:
  wordpress:
    external: true

我知道安全設置是正確的,因為我在端口 80 和 81 上有其他網站,包括“0.0.0.0:81->5000/tcp”上的 Docker“training/webapp:latest”圖像/容器。

我在 a.env 文件中有數據庫連接環境變量:

WORDPRESS_DB_HOST=wordpress.*************.us-west-2.rds.amazonaws.com
WORDPRESS_DB_PORT=3306
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_PASSWORD=**********************
WORDPRESS_DB_NAME=wordpress

我知道 AWS RDS MySQL 數據庫可以使用上述憑證,因為我可以使用 EC2 服務器上 Ubuntu 中的命令行 MySQL 程序連接到它,也可以在我的桌面計算機上使用 Heidi。

When I go to my browser and type in either the public DNS address (something like http://ec2- - - - .us-west-2.compute.amazonaws.com:82/) or the public IP address (something like . . . . :82) 它只是超時了。 我嘗試在兩個地址后添加 /wp-admin,但它立即超時。

我正在使用 wordpress:5.4.1-php7.2-fpm-alpine 圖像,因為在我得到這個概念驗證工作后,我將把它放在我現有的 Nginx 反向代理服務器 Z2567A5EC92705017AC8 之后子域。 有人告訴我 Nginx 需要 PHP FPM 圖像,我已經在幾個教程中看到了它。

我很震驚,我的瀏覽器中沒有任何內容。 這應該很簡單,而我一直在做更復雜的事情。 我已經按照幾個教程說了同樣的話,但它在瀏覽器中根本不起作用。

非常奇怪的是,如果我在本地台式計算機上執行完全相同的操作,然后將 go 轉到 localhost:82,則會出現初始 WordPress 設置。 我似乎無法在我的 AWS EC2 服務器上做同樣的事情。

同樣,我在該 EC2 服務器上運行了一些其他 web 應用程序,使用 Nginx 和端口 80 和 81,所以我知道服務器工作正常,並且安全設置是正確的。

我想到了。 由於某種原因,特定的“fpm-alpine”圖像無法正常工作。 我切換到 wordpress:latest image 並且它有效......多么愚蠢的解決方案。

現在用 Nginx 配置非 FPM 映像,只需按照這篇很棒的文章中的步驟操作,它解決了我所有的問題!

# image: wordpress:5.4.1-php7.2-fpm-alpine
image: wordpress:latest

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM