首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Drupal -数据库设置的最佳实践

问Drupal -数据库设置的最佳实践
EN

Stack Overflow用户
提问于 2017-07-02 13:57:34
回答 1查看 63关注 0票数 0

在Drupal中,配置数据库设置(数据库、用户名、密码、主机等)的最佳实践是什么?

在sites/default/default.settings.php中,它声明如下:

代码语言:javascript
复制
/**
 * 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();

但是,如果您的开发环境和生产环境将具有不同的数据库设置,怎么办?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-03 13:37:42

Drupal支持多个站点。您可以将它用于开发、分期和生产的多个配置。

在sites文件夹中使用您的开发、暂存和生产域的名称创建一个文件夹,每个域都有自己的settings.php文件,这意味着它们将拥有单独的数据库连接配置。Drupal将根据当前使用的域自动选择正确的文件夹。

通常,我设置了三个文件夹:

  • development.myproject.com
  • staging.myproject.com
  • myproject.com (生产)

如果您创建的文件夹恰好是域名,则配置sites.php是可选的。如果您想通过路径访问(例如,sites.php ),可以配置myproject.com/devel。

在Drupal文档中有更多的信息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44871554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档