另一种SuiteCRM安装方法

SuiteCRM安装
SuiteCRM安装

您可能偶尔需要通过一些自动化过程来安装SuiteCRM。SuiteCRM提供了一种进行“静默”安装的方法,当给定包含某些安装详细信息的config_si.php文件时,它将执行安装。涉及的步骤非常简单。首先,我们在SuiteCRM根目录中创建一个config_si.php文件:

<?php
$sugar_config_si  = array (
    'dbUSRData' => 'create',
    'default_currency_iso4217' => 'USD',
    'default_currency_name' => 'US Dollar',
    'default_currency_significant_digits' => '2',
    'default_currency_symbol' => '$',
    'default_date_format' => 'Y-m-d',
    'default_decimal_seperator' => '.',
    'default_export_charset' => 'ISO-8859-1',
    'default_language' => 'en_us',
    'default_locale_name_format' => 's f l',
    'default_number_grouping_seperator' => ',',
    'default_time_format' => 'H:i',
    'export_delimiter' => ',',
    'setup_db_admin_password' => 'DB Password',
    'setup_db_admin_user_name' => 'DB Username',
    'setup_db_create_database' => 1,
    'setup_db_database_name' => 'DB Name',
    'setup_db_drop_tables' => 0,
    'setup_db_host_name' => 'DB Host',
    'setup_db_pop_demo_data' => false,
    'setup_db_type' => 'mysql',
    'setup_db_username_is_privileged' => true,
    'setup_site_admin_password' => 'Admin Password',
    'setup_site_admin_user_name' => 'Admin username',
    'setup_site_url' => 'Site URL',
    'setup_system_name' => 'Site Name',
  );

其中应包含适当的数据库凭据以及新的SuiteCRM安装站点url,管理员用户名等。例如,如果您转到适当的SuiteCRM位置,则将该文件放置在适当的位置

example.com/install.php?goto=SilentInstall&cli=true对于命令行或example.com/install.php?goto=SilentInstall在浏览器中使用,则SuiteCRM将执行独立安装。或者,您也可以在终端中调用以下命令:

php -r "\$_SERVER['HTTP_HOST'] = 'localhost'; \$_SERVER['REQUEST_URI'] = 'install.php';\$_REQUEST = array('goto' => 'SilentInstall', 'cli' => true);require_once 'install.php';";

以下脚本采用必需的参数,包括未压缩的SuiteCRM软件包的位置,并将创建必要的配置文件并运行安装:

<?php

/*
 * php suitecrmsilentinstall.php --install_location /var/www/html/suitecrmpath --db_host localhost --db_user dbuser --db_pass dbpass --db_name dbname --site_username admin --site_pass password --site_host example.com --site_name "SuiteCRM Silent Install"
 */
$args = getArguments();
createConfigFile($args);
$url = "http://".$args['site_host']."/install.php?goto=SilentInstall&cli=true";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$results = curl_exec($ch);
$matches = array();
preg_match("/<bottle>(.*)<\/bottle>/s",$results,$matches);
echo "Install message was: ".$matches[1]."\n";

function getCLIArguments(){
  return getopt("",array("install_location:","db_host:","db_user:","db_pass:","db_name:","site_username:","site_pass:","site_host:","site_name:"));
}

function getArguments(){
  return getCLIArguments();
}

function createConfigFile($args){
    $installLoc = $args['install_location'];
    $config = createConfigArray($args);
    $contents = '<?php'."\n".'$sugar_config_si = '.var_export($config,1).";\n";
    file_put_contents($installLoc.'/config_si.php',$contents);
}

function createConfigArray($args){
  $dbUser = $args['db_user'];
  $dbPass = $args['db_pass'];
  $dbName = $args['db_name'];
  $dbHost = $args['db_host'];
  $siteUserName = $args['site_username'];
  $siteUserPass = $args['site_pass'];
  $siteHost = $args['site_host'];
  $siteName = $args['site_name'];
  $configArr = array (
    'dbUSRData' => 'create',
    'default_currency_iso4217' => 'USD',
    'default_currency_name' => 'US Dollar',
    'default_currency_significant_digits' => '2',
    'default_currency_symbol' => '$',
    'default_date_format' => 'Y-m-d',
    'default_decimal_seperator' => '.',
    'default_export_charset' => 'ISO-8859-1',
    'default_language' => 'en_us',
    'default_locale_name_format' => 's f l',
    'default_number_grouping_seperator' => ',',
    'default_time_format' => 'H:i',
    'export_delimiter' => ',',
    'setup_db_admin_password' => $dbPass,
    'setup_db_admin_user_name' => $dbUser,
    'setup_db_create_database' => 1,
    'setup_db_database_name' => $dbName,
    'setup_db_drop_tables' => 0,
    'setup_db_host_name' => $dbHost,
    'setup_db_pop_demo_data' => false,
    'setup_db_type' => 'mysql',
    'setup_db_username_is_privileged' => true,
    'setup_site_admin_password' => $siteUserPass,
    'setup_site_admin_user_name' => $siteUserName,
    'setup_site_url' => $siteHost,
    'setup_system_name' => $siteName,
  );
  return $configArr;
}

与往常一样,您应该始终在运行在Internet上找到的代码之前进行备份。

推荐阅读

  1. SuiteCRM 8.1.2 刚刚发布!
  2. SuiteCRM 8.1.1 & 7.12.6 发布
  3. 为了官方更好的技术服务,请捐赠SuiteCRM
  4. SuiteCRM 8.1发布-官方版本再更新!
  5. 苏格兰公司 SuiteCRM 再次获奖
  6. 安全和维护补丁:SuiteCRM 8.0.4 & 7.12.5 发布
  7. 将 SuiteCRM 升级到更新版本
  8. SuiteCRM 升级环境(PHP\MySQL\Apache)要求

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注