Steven Aguilar
Steven Aguilar

Reputation: 3049

Warning: require_once(/var/www/html/wp-config.php): failed to open stream: No such file or directory

I have been working on the following program from the last 6 hours using previous post on this issue without success. I'm currently working on a WP site on top of a Docker boiler plate. When I run docker-compose up and navigate to localhost:8080 I get the following error:

enter image description here

On the server side I get the following Warning:

mysql_1       | 2018-06-12T20:03:03.976722Z 0 [Note] mysqld: ready for connections.
mysql_1       | Version: '5.7.22'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
wordpress_1   | WordPress not found in /var/www/html - copying now...
wordpress_1   | WARNING: /var/www/html is not empty - press Ctrl+C now if this is an error!

wp-load.php:

/** Define ABSPATH as this file's directory */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}

error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );

/*
 * If wp-config.php exists in the WordPress root, or if it exists in the root and wp-settings.php
 * doesn't, load wp-config.php. The secondary check for wp-settings.php has the added benefit
 * of avoiding cases where the current directory is a nested installation, e.g. / is WordPress(a)
 * and /blog/ is WordPress(b).
 *
 * If neither set of conditions is true, initiate loading the setup process.
 */
if ( file_exists( ABSPATH . 'wp-config.php') ) {

    /** The config file resides in ABSPATH */
    require_once( ABSPATH . 'wp-config.php' );

} elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {

    /** The config file resides one level above ABSPATH but is not part of another installation */
    require_once( dirname( ABSPATH ) . '/wp-config.php' );

} else {

    // A config file doesn't exist

    define( 'WPINC', 'wp-includes' );
    require_once( ABSPATH . WPINC . '/load.php' );

    // Standardize $_SERVER variables across setups.
    wp_fix_server_vars();

    require_once( ABSPATH . WPINC . '/functions.php' );

    $path = wp_guess_url() . '/wp-admin/setup-config.php';

    /*
     * We're going to redirect to setup-config.php. While this shouldn't result
     * in an infinite loop, that's a silly thing to assume, don't you think? If
     * we're traveling in circles, our last-ditch effort is "Need more help?"
     */
    if ( false === strpos( $_SERVER['REQUEST_URI'], 'setup-config' ) ) {
        header( 'Location: ' . $path );
        exit;
    }

docker-compose.yml

wordpress: # name of our wordpress container
    depends_on: # container dependencies that need to be running first
      - mysql
    # image: wordpress:latest # image used by our container
    image: wordpress:4.9.6-php7.0 # image used by our container
    ports:
      - "8080:80" # setting our ports for networking
    restart: always
    volumes: # this is where we tell Docker what to pay attention to
      - ./app/wp-content:/var/www/html/wp-content # mapping our custom theme to the container
      - ./app/wp-config.php:/var/www/html/wp-config.php # map our plugins to the container
    networks:
      - back

Can't seem to find what the issue is?

Upvotes: 0

Views: 2376

Answers (1)

andy magoon
andy magoon

Reputation: 2929

The volumes in your docker-compose file are too specific -- you need to expose a /var/www/html directory mount itself, and not just the wp-content or (ack!) the wp-config.php file.

Upvotes: 1

Related Questions