Create cPanel account via terminal
cPanel comes with a script called createacct
(English) to create accounts from the command line. You can use it to resolve the account creation issue:
/scripts/createacct example.com utilizador password
The problem with this command when we want to use it from a script is that he asks for confirmation of some things when he is executed.
This can be bypassed as we read in this topic (English) from the cPanel forum which provides us with a link to:
How to make the /scripts/createacct
non-interactive (English)
PKGRESTORE=1 /scripts/createacct example.com utilizador password
└─────┬────┘ └─────────────────────────┬────────────────────────┘
executar em o comando para
modo não criação de uma conta
interactivo a partir do terminal
PHP and SSH
To make use of SSH through PHP, assuming it’s your idea, you need to install the following PECL extension:
PHP SSH2 Installing/Configuring (English)
Then just make a connection and run the script which contains the above command.
Consult the manual PHP Secure Shell2 (English) to see how to do each of the steps. I was going to put it here, but it’s long and if you don’t know it, you’ll always need to read the manual.
PHP and SSH (without installing extension)
If you need to connect to a server via SSH but cannot install the ssh2 extension, the following pure PHP implementation can solve your question:
PHP Secure Communications Library - Net_ssh (English)
Example:
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.example.com');
if (!$ssh->login('utilizador', 'password')) {
exit('Login Falhou');
}
echo $ssh->exec('meuScript');
echo $ssh->exec('ls -la');
?>