Create cPanel account via terminal
cPanel comes with a script called createacct
/ sup> 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 the same from a script is that it asks for confirmation of some things when it is executed.
This can be bypassed as we read in this topic (English) of the cPanel forum that tells us a link to:
How to make non-interactive /scripts/createacct
(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 to be your idea, you need to install the following PECL extension:
PHP SSH2 Installing / Configuring (English)
Then just establish a connection and execute the script that contains the above command.
See the PHP Secure Shell2 manual (English) for you will see how to do each of the steps. I would put it here, but it's extensive and if you do not know, you'll always need to read the manual.
PHP and SSH (without installing the extension)
If you need to connect to a server via SSH but you can not 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');
?>