{"id":2242,"date":"2019-01-02T10:02:47","date_gmt":"2019-01-02T10:02:47","guid":{"rendered":"http:\/\/www.softaculous.com\/blog\/docs\/api\/auto-install-api\/"},"modified":"2022-07-25T12:26:02","modified_gmt":"2022-07-25T12:26:02","slug":"auto-install-api","status":"publish","type":"docs","link":"https:\/\/www.softaculous.com\/blog\/docs\/api\/auto-install-api\/","title":{"rendered":"Auto Install API"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you wish to automate the installation of Scripts using a different software e.g. a billing system like WHMCS you can do that in Softaculous as there is an API Class which enables us to do so.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">API Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can find the API Class in your Softaculous folder e.g. in cPanel its located here&nbsp;: <\/p>\n\n\n\n<p class=\"bash hljs wp-block-paragraph\">\/usr\/local\/cpanel\/whostmgr\/docroot\/cgi\/softaculous\/sdk\/installapi.php<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Understanding the API<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The API is a simple class which will pass the data to Softaculous to install a script. Here is a sample example to install a script&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">&lt;?php\n\n@set_time_limit(100);\n\n$new = new Soft_Install();\n$new->login = 'https:\/\/'.rawurlencode(\"user\").':'.rawurlencode(\"password\").'@domain.com:2083\/frontend\/jupiter\/softaculous\/index.live.php';\n$new->data['softdomain'] = 'domain.com'; \/\/ OPTIONAL - By Default the primary domain will be used\n$new->data['softdirectory'] = 'folder'; \/\/ OPTIONAL - By default it will be installed in the \/public_html folder\n$new->data['admin_pass'] = 'qwerty';\n$new->data['admin_email'] = 'admin@domain.com';\n$res = $new->install(26); \/\/ Will install WordPress\n\nif($res == 'installed'){\n\techo 'Installed';\n}else{\n\techo $res; \/\/ A serialized array of error will be returned\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As you may see this will install WordPress.&nbsp;<br>Lets go through the Code&nbsp;:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Initializing and Authentication<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">$new = new Soft_Install();\n$new->login = 'https:\/\/'.rawurlencode(\"user\").':'.rawurlencode(\"password\").'@domain.com:2083\/frontend\/jupiter\/softaculous\/index.live.php';<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will load the Class in $new and we are setting the LOGIN URL as without authentication you will not be able to access Softaculous. The code here is an example to Auto Install in cPanel. cPanel allows User Authentication via the URL itself and many other panels also.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">https:\/\/'.rawurlencode(\"user\").':'.rawurlencode(\"password\").'@domain.com:2083<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Installing scripts as ROOT<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can install a script for your user as ROOT. You will have to modify your login URL as follows&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">$new = new Soft_Install();\n$new->login = 'https:\/\/'.rawurlencode(\"user\").':'.rawurlencode(\"ROOT_PASSWORD\").'@domain.com:2083\/frontend\/jupiter\/softaculous\/index.live.php';<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The above code will allow you to install a script as ROOT for your users.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your panel has some different method, you must first implement that code and then proceed.<\/p>\n\n\n\n<p class=\"alert alert-info wp-block-paragraph\"><strong>NOTE&nbsp;:&nbsp;<\/strong>This is the URL which is used to install ANY Script. Hence it is very important to install any script.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Dont send emails<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you want no emails to be sent by Softaculous on the installation of a script please pass the&nbsp;<strong>&amp;noemail=1&amp;<\/strong>&nbsp;in the login url. e.g&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">$new->login = 'https:\/\/'.rawurlencode(\"user\").':'.rawurlencode(\"password\").'@domain.com:2083\/frontend\/jupiter\/softaculous\/index.live.php?&amp;noemail=1&amp;';<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Data Fields<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Softaculous will expect you to submit the data fields as it shows during the installation of Scripts. Now most scripts have common fields like Admin Username and Password and stuff like that. The values that you pass for the fields in this API Call will replace the default ones shown in Softaculous. If you dont specify any field the default value is used by Softaculous.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">$new-&gt;data['softdomain'] = 'domain.com'; \/\/ OPTIONAL - By Default the primary domain will be used\n$new-&gt;data['softdirectory'] = 'folder'; \/\/ OPTIONAL - By default it will be installed in the \/public_html folder\n$new-&gt;data['admin_pass'] = 'qwerty';\n$new-&gt;data['admin_email'] = 'admin@domain.com';\n$res = $new-&gt;install(26); \/\/ Will install WordPress<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The above code is just setting the Domain, Folder to install in, Admin Password and Admin Email.&nbsp;<br>The field names for each script can be obtained by viewing the SOURCE in the browser while installing a Script in Softaculous.<br>The line&nbsp;<strong>$res = $new-&gt;install(26);<\/strong>&nbsp;will start the installation process and $res will have the result that is obtained.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Return Values<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">if($res == 'installed'){\n\techo 'Installed';\n}else{\n\techo $res; \/\/ A serialized array of error will be returned\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a successful install $res will have the value&nbsp;<strong>installed<\/strong>&nbsp;<br>On error a SERIALIZED PHP ARRAY is returned with the error details.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Custom Scripts<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you have made Custom Script packages and would like to use this API to install it just copy the&nbsp;<strong>cscripts.php<\/strong>&nbsp;from your server and place it next to this file.<br>Thats it!! You can now install the Custom Scripts.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Overwrite Files<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you wish to install the software even if the files exists you need to uncomment following line in the file installapi.php<\/p>\n\n\n\n<pre class=\"wp-block-preformatted php hljs\">$new-&gt;data['overwrite_existing'] = true;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Support<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can always ask us if you have any queries. The support department can be accessed from here&nbsp;:&nbsp;<a href=\"https:\/\/www.softaculous.net\/support\/\">https:\/\/www.softaculous.net\/support\/<\/a><\/p>\n","protected":false},"featured_media":0,"parent":1683,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","docs_category":[],"class_list":["post-2242","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/2242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/comments?post=2242"}],"version-history":[{"count":15,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/2242\/revisions"}],"predecessor-version":[{"id":6937,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/2242\/revisions\/6937"}],"up":[{"embeddable":true,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs\/1683"}],"wp:attachment":[{"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/media?parent=2242"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/www.softaculous.com\/blog\/wp-json\/wp\/v2\/docs_category?post=2242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}