Automated Installation

This section is intended for software installer vendors. You can automate the installation of SCHLIX CMS by just using HTTP POST to /install/index.php or by storing the variables in environment variables. Upon completion, the /install folder will also be deleted automatically, unlike the manual install. The following is a sample code on how to perform an automatic installation with just a single PHP script. The variables will be obtained from user input, which will be provided by your installer.

A. HTTP POST

Please ensure that the auto_install variable is set to 9.

<?php 

function __perform_http_post($url, $postvars)
{
    $str_postvars = '';
    foreach ($postvars as $key=> $value)
    {
        $str_postvars .= $key.'='.urlencode ($value).'&';
    }
    rtrim($str_postvars, '&');

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($postvars));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $str_postvars);

    //execute post
    $result = curl_exec($ch);

    //close connection
    curl_close($ch);
    return $result;
}

function __perform_installation()
{

    $site_full_url = 'https://samplesite.com/siteprefixhttpbase';

    // To perform auto install, add auto_install = 9 to post variables
    $post_vars = array (
      'auto_install' => 9, // keep this to 9
      'agree_term' => true,  // must be set to true
      'db_host' => $db_host, // Host name
      'db_database' => $db_name,  // Database
      'db_username' => $db_user,   // Username
      'db_password' => $db_pass,  // Password
      'site_domain_name' => $url_domain,  // domain name without https
      'site_use_https' => false,  // true/false
      'site_httpbase' => $site_httpbase,  // the path relative to root
      'site_name' => $input['field_sitetitle'],  // Site Title, e.g. My Website
      'site_root_file_path' => $path,   // The root path of the installation
      'site_id' => 'main',  // This is the first site, keep this as "main"
      'email_from' => 'Webmaster',  // The sender name
      'email_address' => $input['field_email'],  // Default from email address
      'admin_username' => $input['field_login'],  // Admin username
      'admin_password' => $input['field_passwd'],  // Admin password
      'sampledata' => $input['field_sampledata'],  // 1 = newspaper sample data, 2 = company profile sample data, or 0 for company profile with no sample data and test pages (updated - Jan 2020)
      'use_wildcard' => $input['field_usewildcard'],   // Wildcard
      'timezone' => $input['field_timezone'], // Must match  http://php.net/manual/en/timezones.php, e.g. America/Edmonton
      'use_www' => $input['use_www'], // new - 2017 July 3 - recommended for single site (non-multisite)
      'db_port' => $input['db_port'], // Database port - default is 3306 if blank
      'db_socket' => $input['db_socket'], // Database socket - most of the time this parameter is empty by default
      'db_use_ssl' => $input['db_use_ssl'], // for Azure - using non-localhost MySQL connection
      'db_ssl_ca' => $input['db_ssl_ca'], // for Azure - if db_use_ssl is selected. The file is assumed to have existed prior to the automated install        
        ); 
   $exec_result = __perform_http_post($site_full_url.'/install/index.php',$post_vars);
}

B. Environment variable

Alternatively, you can use a pre-set environment variable, then execute the /install/index.php. Please ensure that the SCHLIX_AUTO_INSTALL variable is set to 8.

Environment variable key Environment variable value
SCHLIX_AUTO_INSTALL must be exactly number 8
SCHLIX_INSTALL_USER_AGREE_TERM must be 1
SCHLIX_INSTALL_DB_HOST database host
SCHLIX_INSTALL_DB_DATABASE database name
SCHLIX_INSTALL_DB_USERNAME database username
SCHLIX_INSTALL_DB_PASSWORD database password
SCHLIX_INSTALL_SITE_DOMAIN_NAME domain name, e.g. www.mywebsite.com
SCHLIX_INSTALL_SITE_USE_HTTPS 1 or 0
SCHLIX_INSTALL_SITE_HTTPBASE leave blank for automatic configuration, or hardcode it here
SCHLIX_INSTALL_SITE_NAME e.g. Newspaper Today
SCHLIX_INSTALL_SITE_ROOT_FILE_PATH leave blank for automatic configuration, or hardcode it here
SCHLIX_INSTALL_SITE_ID website name, e.g. main, or mywebsite (alphanumeric only)
SCHLIX_INSTALL_EMAIL_FROM Email sender name, e.g. Company Name Ltd Webmaster
SCHLIX_INSTALL_EMAIL_ADDRESS Email address, e.g. info@localhost.local
SCHLIX_INSTALL_ADMIN_USERNAME Web administrator username, e.g. admin
SCHLIX_INSTALL_ADMIN_PASSWORD Minimum 7 characters password
SCHLIX_INSTALL_USE_SAMPLE_DATA 0, 1, or 2. (Updated Jan 2020)
0 = company profile with no sample data and test pages
1 = newspaper sample data
2 = company profile sample data
SCHLIX_INSTALL_HOST_USE_WILDCARD whether install should use wildcard. Recommended: 0 (no). This is for advanced multi-site configuration only
SCHLIX_INSTALL_TIMEZONE Timezone name, must match https://www.php.net/manual/en/timezones.php or simply set to UTC
SCHLIX_INSTALL_HOST_ADD_WWW recommended = 1 for production public facing website, 0 for development
SCHLIX_INSTALL_DB_PORT MySQL port number (or leave blank or 0 for default)
SCHLIX_INSTALL_DB_SOCKET MySQL socket, simply leave blank for automatic onfiguration
SCHLIX_INSTALL_DB_USE_SSL Option to set SSL for database connection for non-localhost database (e.g. Azure)
SCHLIX_INSTALL_DB_SSL_CA Option to set SSL Certificate Authority file (e.g. Azure)