admin管理员组

文章数量:1122846

There doesn't appear to be a wp-config.php file in the root folder of my wp install. There is one in the file directory up but it doesn't provide any of the usual details, it only shows as per the below:

<?php
/**
 * Do not edit this file. Edit the config files found in the config/ dir instead.
 * This file is required in the root directory so WordPress can find it.
 * WP is hardcoded to look in its own directory or one directory up for wp-config.php.
 */
require_once(dirname(__DIR__) . '/vendor/autoload.php');
require_once(dirname(__DIR__) . '/config/application.php');
require_once(ABSPATH . 'wp-settings.php');"

There doesn't appear to be a wp-config.php file in the root folder of my wp install. There is one in the file directory up but it doesn't provide any of the usual details, it only shows as per the below:

<?php
/**
 * Do not edit this file. Edit the config files found in the config/ dir instead.
 * This file is required in the root directory so WordPress can find it.
 * WP is hardcoded to look in its own directory or one directory up for wp-config.php.
 */
require_once(dirname(__DIR__) . '/vendor/autoload.php');
require_once(dirname(__DIR__) . '/config/application.php');
require_once(ABSPATH . 'wp-settings.php');"
Share Improve this question edited May 21, 2024 at 16:33 Tom J Nowell 60.7k7 gold badges77 silver badges147 bronze badges asked May 21, 2024 at 16:22 WillWill 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

There is one in the file directory up

That is your wp-config.php, WordPress can look one folder up so that you can place the file in a folder that's not served to the web. This is done as a security measure.

it doesn't provide any of the usual details

wp-config.php is still a PHP file, as long as loading that file defines what's needed you don't need to do it the normal way. Your wp-config.php could bootstrap a whole other CMS and query it for the database details/login/prefix/etc, or fire a remote request!

On some of the sites I work with, the constants are placed in individual files so that I can conditionally load them based on the environment, e.g. wp-local-config.php might be loaded for local development, but not on the production server, providing different DB details and constants.

Instead it looks like your wp-config.php does 3 things:

  1. Load the Composer autoloader for Composer packages and other stuff in the vendor folder
  2. Load a config/application.php that takes care of all the constants such as DB host etc
  3. Loads wp-settings.php as all wp-config.php files are supposed to do

本文标签: Updating wpconfigphp but it doesnt seem to exist