Нема описа

wp-config-docker.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * The base configuration for WordPress
  4. *
  5. * The wp-config.php creation script uses this file during the installation.
  6. * You don't have to use the web site, you can copy this file to "wp-config.php"
  7. * and fill in the values.
  8. *
  9. * This file contains the following configurations:
  10. *
  11. * * MySQL settings
  12. * * Secret keys
  13. * * Database table prefix
  14. * * ABSPATH
  15. *
  16. * This has been slightly modified (to read environment variables) for use in Docker.
  17. *
  18. * @link https://wordpress.org/support/article/editing-wp-config-php/
  19. *
  20. * @package WordPress
  21. */
  22. // IMPORTANT: this file needs to stay in-sync with https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php
  23. // (it gets parsed by the upstream wizard in https://github.com/WordPress/WordPress/blob/f27cb65e1ef25d11b535695a660e7282b98eb742/wp-admin/setup-config.php#L356-L392)
  24. // a helper function to lookup "env_FILE", "env", then fallback
  25. if (!function_exists('getenv_docker')) {
  26. // https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
  27. function getenv_docker($env, $default) {
  28. if ($fileEnv = getenv($env . '_FILE')) {
  29. return rtrim(file_get_contents($fileEnv), "\r\n");
  30. }
  31. else if (($val = getenv($env)) !== false) {
  32. return $val;
  33. }
  34. else {
  35. return $default;
  36. }
  37. }
  38. }
  39. // ** MySQL settings - You can get this info from your web host ** //
  40. /** The name of the database for WordPress */
  41. define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );
  42. /** MySQL database username */
  43. define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );
  44. /** MySQL database password */
  45. define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );
  46. /**
  47. * Docker image fallback values above are sourced from the official WordPress installation wizard:
  48. * https://github.com/WordPress/WordPress/blob/f9cc35ebad82753e9c86de322ea5c76a9001c7e2/wp-admin/setup-config.php#L216-L230
  49. * (However, using "example username" and "example password" in your database is strongly discouraged. Please use strong, random credentials!)
  50. */
  51. /** MySQL hostname */
  52. define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') );
  53. /** Database charset to use in creating database tables. */
  54. define( 'DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8') );
  55. /** The database collate type. Don't change this if in doubt. */
  56. define( 'DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', '') );
  57. /**#@+
  58. * Authentication unique keys and salts.
  59. *
  60. * Change these to different unique phrases! You can generate these using
  61. * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
  62. *
  63. * You can change these at any point in time to invalidate all existing cookies.
  64. * This will force all users to have to log in again.
  65. *
  66. * @since 2.6.0
  67. */
  68. define( 'AUTH_KEY', getenv_docker('WORDPRESS_AUTH_KEY', 'put your unique phrase here') );
  69. define( 'SECURE_AUTH_KEY', getenv_docker('WORDPRESS_SECURE_AUTH_KEY', 'put your unique phrase here') );
  70. define( 'LOGGED_IN_KEY', getenv_docker('WORDPRESS_LOGGED_IN_KEY', 'put your unique phrase here') );
  71. define( 'NONCE_KEY', getenv_docker('WORDPRESS_NONCE_KEY', 'put your unique phrase here') );
  72. define( 'AUTH_SALT', getenv_docker('WORDPRESS_AUTH_SALT', 'put your unique phrase here') );
  73. define( 'SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', 'put your unique phrase here') );
  74. define( 'LOGGED_IN_SALT', getenv_docker('WORDPRESS_LOGGED_IN_SALT', 'put your unique phrase here') );
  75. define( 'NONCE_SALT', getenv_docker('WORDPRESS_NONCE_SALT', 'put your unique phrase here') );
  76. // (See also https://wordpress.stackexchange.com/a/152905/199287)
  77. /**#@-*/
  78. /**
  79. * WordPress database table prefix.
  80. *
  81. * You can have multiple installations in one database if you give each
  82. * a unique prefix. Only numbers, letters, and underscores please!
  83. */
  84. $table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
  85. /**
  86. * For developers: WordPress debugging mode.
  87. *
  88. * Change this to true to enable the display of notices during development.
  89. * It is strongly recommended that plugin and theme developers use WP_DEBUG
  90. * in their development environments.
  91. *
  92. * For information on other constants that can be used for debugging,
  93. * visit the documentation.
  94. *
  95. * @link https://wordpress.org/support/article/debugging-in-wordpress/
  96. */
  97. define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') );
  98. /* Add any custom values between this line and the "stop editing" line. */
  99. // If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
  100. // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
  101. if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
  102. $_SERVER['HTTPS'] = 'on';
  103. }
  104. // (we include this by default because reverse proxying is extremely common in container environments)
  105. if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
  106. eval($configExtra);
  107. }
  108. /* That's all, stop editing! Happy publishing. */
  109. /** Absolute path to the WordPress directory. */
  110. if ( ! defined( 'ABSPATH' ) ) {
  111. define( 'ABSPATH', __DIR__ . '/' );
  112. }
  113. /** Sets up WordPress vars and included files. */
  114. require_once ABSPATH . 'wp-settings.php';