在Drupal中,配置数据库设置(数据库、用户名、密码、主机等)的最佳实践是什么?
在sites/default/default.settings.php中,它声明如下:
/**
* Database settings:
*
* The $databases array specifies the database connection or
* connections that Drupal may use. Drupal is able to connect
* to multiple databases, including multiple types of databases,
* during the same request.
*
* One example of the simplest connection array is shown below. To use the
* sample settings, copy and uncomment the code below between the @code and
* @endcode lines and paste it after the $databases declaration. You will need
* to replace the database username and password and possibly the host and port
* with the appropriate credentials for your database system.
*
* The next section describes how to customize the $databases array for more
* specific needs.
*
* @code
* $databases['default']['default'] = array (
* 'database' => 'databasename',
* 'username' => 'sqlusername',
* 'password' => 'sqlpassword',
* 'host' => 'localhost',
* 'port' => '3306',
* 'driver' => 'mysql',
* 'prefix' => '',
* 'collation' => 'utf8mb4_general_ci',
* );
* @endcode
*/
$databases = array();但是,如果您的开发环境和生产环境将具有不同的数据库设置,怎么办?
发布于 2017-07-03 13:37:42
Drupal支持多个站点。您可以将它用于开发、分期和生产的多个配置。
在sites文件夹中使用您的开发、暂存和生产域的名称创建一个文件夹,每个域都有自己的settings.php文件,这意味着它们将拥有单独的数据库连接配置。Drupal将根据当前使用的域自动选择正确的文件夹。
通常,我设置了三个文件夹:
如果您创建的文件夹恰好是域名,则配置sites.php是可选的。如果您想通过路径访问(例如,sites.php ),可以配置myproject.com/devel。
在Drupal文档中有更多的信息。
https://stackoverflow.com/questions/44871554
复制相似问题