0

I'm trying to figure out, why my assets like CSS, JS and images are not loading in my theme when running installation on Docker.

Here's my docker-compose.yml

version: "3.3"
services:
  db:
    image: mysql:8
    container_name: blogpn_mysql
    restart: always
    command: "--default-authentication-plugin=mysql_native_password"
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wpdb
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - blogpn_network
  wordpress:
    image: wordpress:latest
    container_name: blogpn_wordpress
    restart: always
    volumes:
      - ./wp-content/themes:/var/www/html/wp-content/themes
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_NAME: wpdb
      WORDPRESS_DB_USER: user
      WORDPRESS_DB_PASSWORD: password
    ports:
      - 8211:80
      - 443:443
    depends_on:
      - db
    networks:
      - blogpn_network
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: blogpn_phpmyadmin
    restart: always
    ports:
      - 3333:80
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: password
volumes:
  db_data: {}
networks:
  blogpn_network: {}

For the files like CSS and JS I'm getting network error 500 (the URL for styles is http://localhost:8211/wp-content/themes/mytheme/style.css), and for images network error 404. I'm not sure what I'm missing.

sunpietro
  • 101
  • 1

1 Answers1

0

I think I ran into something similar recently and it turned out to be file ownership issues.

I attached to the container's console and ran the following in the /var/www/html/ directory (source of that linked below):

chown www-data:www-data  -R *
find . -type d -exec chmod 755 {} \;  
find . -type f -exec chmod 644 {} \;

From there definitely spend time going through Wordpress hardening to ensure your final permissions are dialed in.

Hope this helps!

OG Article I used: https://stackoverflow.com/questions/18352682/correct-file-permissions-for-wordpress

S3ntinel
  • 1
  • 2