Error establishing a database connection
deviland opened this issue ยท 16 comments
Hi @urre thanks for creating this repo.
I have run the steps and have ran docker compose up -d and everything seems fine but I do get the above error
from Wordpress when I attempt to load the admin.
I also see that the composer container is not running should it be?
thanks in advance for your help
I include the env file below
IP=127.0.0.1
APP_NAME=themetest
DOMAIN=themetest.local
DB_HOST=mysql
DB_NAME=themetest
DB_ROOT_PASSWORD=password
DB_TABLE_PREFIX=wp_
Hi, what error did you get in wp-admin?
HI the same error, I'm going through the process again to see if I've made a mistake somewhere
Hey @urre I reran the steps in the guide and got the same result have I got something wrong in the above .env file? this is the only place I have edited
did you install using docker-compose run composer create-project?
yes this works and I can see the requests coming through to nginx
themetest-wordpress | 192.168.0.7 - 04/Mar/2021:15:40:08 +0000 "GET /index.php" 500
themetest-nginx | 192.168.0.1 - - [04/Mar/2021:15:40:08 +0000] "GET / HTTP/2.0" 500 2609 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15"
themetest-wordpress | 192.168.0.7 - 04/Mar/2021:15:40:13 +0000 "GET /index.php" 500
themetest-nginx | 192.168.0.1 - - [04/Mar/2021:15:40:13 +0000] "GET /wp-admin HTTP/2.0" 500 2609 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15"
themetest-mailhog | [APIv1] KEEPALIVE /api/v1/events
think I'm getting closer the logs from docker compose run compose create-project
I'm getting
Creating wordpress-nginx-docker-compose-master_composer_run ... done
> php -r "copy('.env.example', '.env');"
Warning: copy(.env.example): Failed to open stream: No such file or directory in Command line code on line 1
I followed the creation of the .env in the root dir
Right. I actually fixed this in a commit yesterday. There was a typo in the example env and no .env got created.
But this is fixed now, can you please do a new pull
Sorry for this. But it's now called .env.example and not .env-example
hey no need to say sorry you're repo will save me hours of work ๐
Glad I can help by feeding back
should I be editing the /.env.example or the /src/.env.example?
I have the latest code now ๐
This is my output now
docker-compose run composer create-project
WARNING: The APP_NAME variable is not set. Defaulting to a blank string.
WARNING: The DOMAIN variable is not set. Defaulting to a blank string.
WARNING: The DB_ROOT_PASSWORD variable is not set. Defaulting to a blank string.
WARNING: The DB_NAME variable is not set. Defaulting to a blank string.
WARNING: The DB_HOST variable is not set. Defaulting to a blank string.
sorry to keep coming back I edited both /.env.example and /src/env.example and still had the above output. I'm sure this is me missing something
You should edit both env example files before you install. Both in the root and in ./src. The file in the root is called ./env-example but in the src it is called ./src/.env.example
Read more in the Readme here under under Instructions
The warnings above you can ignore for now.
If you run docker-compose up -d and head over to https://myapp.local/wp/wp-admin now it should work fine. You you should see this screen:
Great! Thanks for your feedback

