Hi,
I am trying to migrate an existing WordPress installation from AMPPS to Docker on my local machine. Every time I visit the site after running docker-compose up
I am confronted with a fresh WordPress install screen. My docker-compose.yml looks like this:
version: '3'
services:
mysite-wp-db:
image: mysql:5.7
volumes:
- ./db/initdb.d:/docker-entrypoint-initdb.d
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: some_user
MYSQL_PASSWORD: pwd
mysite-wp:
depends_on:
- mysite-wp-db
image: wordpress:latest
restart: always
expose:
- "80"
environment:
- VIRTUAL_PORT=80
- VIRTUAL_HOST=mysite.local
volumes:
- ./wp/wp-content:/var/www/html/wp-content
- ./wp/wp-config.php:/var/www/html/wp-config.php
networks:
default:
external:
name: mysite-nginx-proxy
I am running the site behind an nginx reverse proxy container. I have mysite.local mapped to 127.0.0.1 in /etc/hosts
.
I populate the db from an sql dump file located under ./db/initdb.d (see the volumes:
section of the mysql container above), and having also run a container with phpmyadmin in this stack I can confirm that it’s being copied over. So what am I doing wrong? Frustratingly I did have this working a few months ago.
Thanks
UPDATE: If I mount my entire WordPress installation directory to the container then it sort of works, but there are problems. So, I now have this:
volumes:
- ./wp:/var/www/html
where wp
is the entrie WordPress folder, containing wp-config.php, wp-content, etc. I no longer get any errors, but when I access http://mysite.local I am always redirected to http://mysite.local/wp/. My AMPPS install was indeed under 127.0.0.1/wp, but I changed all of the links in my db text dump from that to mysite.local. Looking at the page source in the browser I can see that wp is being appended to mysite.local for all of the resources… if I remove it I can however access these resources - logos, JS files and CSS files, etc… it’s all there, just with wp added where it shouldn’t be… I don’t get this.
I have the standard .htaccess file in my wp folder, which looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
SOLVED: I had neglected to remove /wp from my 'siteurl'
and 'home'
entries in my database dump file… gah! It’s working now… although it seems only if I mount the entire original WordPress installation directory from AMPPS to var/www/html.
Sorry for the noise.