acme.sh renew

source : https://www.howtoforge.com/getting-started-with-acmesh-lets-encrypt-client/#renew-the-lets-encrypt-ssl-certs

Install Let’s encrypt SSL cert

Apache example:

acme.sh --install-cert \
--domain example.com \
--cert-file /path/to/cert/cert.pem \
--key-file /path/to/keyfile/key.pem \
--fullchain-file /path/to/fullchain/fullchain.pem \
--reloadcmd "sudo systemctl reload apache2.service"

Renew the Let’s Encrypt SSL certs

acme.sh --renew -d example.com --force

ISPConfig 3 API, List all domain_id

Attention: Before using this script, you MUST KNOW how to use ISPConfig API. If you are first time to learning ISPConfig API, Please go to see First time test ISPConfig API learning how to config, how to run it and how to debug with https.

File name: sites_web_domain_id_get_all.php
<?php

require 'soap_config.php';

$context = stream_context_create([
    'ssl' => [
        // set some SSL/TLS specific options
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    ]
]);

$client = new SoapClient(null, array('location' => $soap_location,
                'uri'      => $soap_uri,
                'trace' => 1,
                'exceptions' => 1,
                'stream_context' => $context));

try {
        if($session_id = $client->login($username, $password)) {
                echo 'Logged successfull. Session ID:'.$session_id.'<br />';
        }


        $domain_record = $client->sites_web_domain_get($session_id, []);
        $domain_ids = array_column($domain_record, 'domain_id');


        print_r($domain_ids);

        if($client->logout($session_id)) {
                echo 'Logged out.<br />';
        }


} catch (SoapFault $e) {
        echo $client->__getLastResponse();
        die('SOAP Error: '.$e->getMessage());
}

?>

First time test ISPConfig API

  • After Install ISPConfig , the application would not saved any API Example or Document. So, we need to find out the example scripts at the source file and copy them to /usr/local/ispconfig.
cd /tmp 
wget -O ispconfig.tar.gz https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xfz ispconfig.tar.gz
cd ispconfig3_install/
cp -R remoting_client/ /usr/local/ispconfig/
cd /usr/local/ispconfig/remoting_client
  • All API Document and example file was copied to /usr/local/ispconfig/remoting_client
  • ISPConfig add Remote Users
ISPConfig Web UI > system > Remote User > Add new user

Entry username & password, And click what do you want function. In first test, please click all Functions. Please remember username & password for modify API config file .

save
  • Modify API config file
cd /usr/local/ispconfig/remoting_client/examples/
nano soap_config.php
<?php

$username = 'admin';
$password = 'admin1234';

/*
$soap_location = 'http://localhost:8080/ispconfig3_3.0.5/interface/web/remote/index.php';
$soap_uri = 'http://localhost:8080/ispconfig3_3.0.5/interface/web/remote/';
*/


$soap_location = 'https://192.168.1.100:8080/remote/index.php';
$soap_uri = 'https://192.168.1.100:8080/remote/';


?>

Change to

<?php

$username = 'username';
$password = 'password';

/*
$soap_location = 'http://localhost:8080/ispconfig3_3.0.5/interface/web/remote/index.php';
$soap_uri = 'http://localhost:8080/ispconfig3_3.0.5/interface/web/remote/';
*/


$soap_location = 'https://localhost:8080/remote/index.php';
$soap_uri = 'https://localhost:8080/remote/';


?>
  • Test First API
php system_config_get.php

If every was ok, you will see the follow message.

Logged successfull. Session ID:qd0758c7265f2498285bef4e2f7ba4a3a25f8c7e3<br />Array
(
    [company_name] => Innonext
    [custom_login_text] =>
    [custom_login_link] =>
    [dashboard_atom_url_admin] => https://www.ispconfig.org/atom
    [dashboard_atom_url_reseller] => https://www.ispconfig.org/atom
    [dashboard_atom_url_client] => https://www.ispconfig.org/atom
    [tab_change_discard] => n
    [tab_change_warning] => n
    [use_loadindicator] => y
    [use_combobox] => y
    [show_support_messages] => y
    [maintenance_mode] => n
    [maintenance_mode_exclude_ips] =>
    [admin_dashlets_left] =>
    [admin_dashlets_right] =>
    [reseller_dashlets_left] =>
    [reseller_dashlets_right] =>
    [client_dashlets_left] =>
    [client_dashlets_right] =>
    [customer_no_template] => C[CUSTOMER_NO]
    [customer_no_start] => 1
    [customer_no_counter] => 5
    [session_timeout] => 0
    [session_allow_endless] => n
    [min_password_length] => 8
    [min_password_strength] => 3
)
  • Normally, It was Done! BUG

But some API have some BUG and not work. This is because the normally working API was disabled ‘ssl verify peer’ when using https connect. So, we need add ‘disabled ssl verify peer’ in not work API.

Test sites_web_domain_get.php, you will get a error message ‘SOAP Error: Could not connect to host

php sites_web_domain_get.php
SOAP Error: Could not connect to host[root@system]#

Fix method, Edit sites_web_domain_get.php

<?php

require 'soap_config.php';

{add something here}

$client = new SoapClient(null, array('location' => $soap_location,
                'uri'      => $soap_uri,
                'trace' => 1,
                'exceptions' => 1{add something here}));


try {
        if($session_id = $client->login($username, $password)) {
                echo 'Logged successfull. Session ID:'.$session_id.'<br />';
        }

        //* Set the function parameters.
        $subdomain_id = 10;

        $subdomain_record = $client->sites_web_subdomain_get($session_id, $subdomain_id);

        print_r($subdomain_record);

        if($client->logout($session_id)) {
                echo 'Logged out.<br />';
        }


} catch (SoapFault $e) {
        echo $client->__getLastResponse();
        die('SOAP Error: '.$e->getMessage());
}

?>

Change to

<?php

require 'soap_config.php';

$context = stream_context_create([
    'ssl' => [
        // set some SSL/TLS specific options
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    ]
]);

$client = new SoapClient(null, array('location' => $soap_location,
                'uri'      => $soap_uri,
                'trace' => 1,
                'exceptions' => 1,
                'stream_context' => $context));

try {
        if($session_id = $client->login($username, $password)) {
                echo 'Logged successfull. Session ID:'.$session_id.'<br />';
        }

        //* Set the function parameters.
        $subdomain_id = 10;

        $subdomain_record = $client->sites_web_subdomain_get($session_id, $subdomain_id);

        print_r($subdomain_record);

        if($client->logout($session_id)) {
                echo 'Logged out.<br />';
        }


} catch (SoapFault $e) {
        echo $client->__getLastResponse();
        die('SOAP Error: '.$e->getMessage());
}

?>

Test sites_web_domain_get.php again

php sites_web_domain_get.php
Logged successfull. Session ID:u3712304db1b527b09cbe8582f141f0614331d551<br />Logged out.<br />[root@system]#
  • Everything Done.
  • You may not research other API in /usr/local/ispconfig/remoting_client/examples.
  • About API Document, you may direct file download to you desktop computer.

https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz

Extract ISPConfig-3-stable.tar.gz in your PC.

You may find a file in extracted folder and run it, Ispconfig3_install\remoting_client\API-docs\index.html

Fixed MySQL replication slave got Last_SQL_Errno: 1062

If you don’t want REDO the complete procedure, a good fix would be to use

STOP SLAVE;    
SET GLOBAL sql_slave_skip_counter=1;
START SLAVE;

If there are too many such errors, a good idea would be to automate it using a bash script.

Reference : Ut xD(2017), https://serverfault.com/questions/336888/what-causes-the-mysql-error-1062-duplicate-entry-when-starting-slave, Last visit at Jan 2022

Manuel SQL backup for ISPConfig by command line

Version 3.1.x

The following command will start cron job backup in advance.

command: cron_debug.php

php /usr/local/ispconfig/server/cron_debug.php --cronjob=500-backup.inc.php

Version 3.2.x

command: backup-now.php

Usage:
php backup-now.php --id=<4> [--type=]
Options:
--id id of the website to backup.
--type backup type: all, web or mysql. Default is all.
php /usr/local/ispconfig/server/backup-now.php --id=1 --type=mysql

ispconfig install Composer

  • Using command line and root login
  • Confirm which user needs to install composer.
  • For example user is ‘web66’
  • Modify /etc/passwd, search web66, change /bin/false to /bin/bash
web66:x:1048:1014::/var/www/clients/client26/web66:/bin/false
{change to}
web66:x:1048:1014::/var/www/clients/client26/web66:/bin/bash
  • chattr -i <Web Directory>
chattr -i /var/www/clients/client26/web66
  • change folder permission
chown web66 /var/www/clients/client26/web66
  • login to web66
su - web66
cd web
  • Download composer-setup.php and install
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  • Check the download file
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
  • Install
php composer-setup.php
  • Delete install file
php -r "unlink('composer-setup.php');"
  • composer version check
composer -V
  • composer package install test
composer require monolog/monolog
  • composer update
composer update
  • Exit to root user
exit
  • chattr +i <Web Directory>
chattr +i /var/www/clients/client26/web66
  • Complete