Overview

The following guide will show you how to install Softaculous Enterprise.
Softaculous Enterprise Integration is suitable for a system where NFS access is possible. Softaculous will be installed on a single VM or dedicated server and will install applications over NFS. Softaculous Enterprise is suitable for a clustered setup where you have multiple servers which are connected over NFS.

Install Softaculous Enterprise

Requirements

A server with Root access.

If you have a firewall, then please allow access to download all packages from *.softaculous.com

Note : Please allow access to the following domains to your firewall as these are the mirrors used to download the script packages.

api.softaculous.com (IP : 192.198.80.3)

s1.softaculous.com (IP : 158.69.6.246)

s2.softaculous.com (IP : 192.200.108.99)

s3.softaculous.com (IP : 178.32.158.97)

s4.softaculous.com (IP : 138.201.24.83)

s7.softaculous.com (IP : 167.114.200.240)

IMPORTANT : Please do not use any other web server on this server because Softaculous will be using its own web server on port 80, 443, 2006 and 2007. Also do not install any other database as MySQL too will be installed by Softaculous and will be using port 3178.

Supported OS

Installing Softaculous

Note the API KEY and API PASSWORD given by the installer in the end. It will be used for Login and verification purpose.

That's it the installation of Softaculous Enterprise is completed!
But you will need to do some coding before you can start using Softaculous.

Integrating

Softaculous Enterprise will need you to write a class which will tell Softaculous which user is logged in, what domains he owns, etc.

You need to create a file called /usr/local/softaculous/enduser/enterprise.php

We have provided a sample file called /usr/local/softaculous/enduser/enterprise.sample.php, so you can refer it to create /usr/local/softaculous/enduser/enterprise.php

There is a class called customPanel which is extended in Softpanel. All the functions which are given in the file are used in Softaculous.

Softpanel is the class created by us which will be the bridge between your panel and the Softaculous.

Don't rename any functions given in the customPanel class as it might break Softaculous.

Codes written in functions are simple examples which should be modified by you.

Below we have explained each function in detail so you can modify easily according to your panel needs.

function customPanel()

function customPanel(){
// Connecting to the database with root privileges. This will be used to create database for any new installations.
// Note: This is not compulsory and just an example
$this->db = mysql_connect('localhost', 'root', 'mysql');
if(!$this->db){
die('Could not establish a connection to a database.');
}
}

This is a Contructor.

If you want to execute anything when customPanel class is loaded you can put it here. For example you can connect to mysql as shown in above example.

function dbhost()

This function is used to connect to a database where softaculous can propagate the database for scripts installed by users.

function maxdb()

//The Maximum Number of Database
function maxdb($type = 'mysql'){
return 100000; // The max number of DBs allowed to this user. If a string is given it will be assumed as Unlimited!
}

Return value should be the max number of DBs allowed to this user. If a string is given it will be assumed as Unlimited!

This function is used to check that the user does not create more databases than allotted to them.

function dbsused()

// Number of dbs used
// If unlimited return a string
function dbsused(){
return 10;
}

This function is called to CHECK whether the existing number of databases is not GREATER than or EQUAL to (>=) the allowed number of Databases.

Return value should be an int or a string. If a string is given it will be assumed as Unlimited!

function dbname()

// Return the DBNAME as per the panel
// e.g if dbname is given and a prefix is required then please give it here
function dbname($dbname){
return $dbname;
}

If the panel requires to modify the DB NAME that is to be created when installing a script, it has to be done here. Many panels e.g. cPanel accept input from users as DBNAME but create Databases like USERNAME_DBNAME. In such a case this function must return USERNAME_DBNAME or DBNAME

Parameter :

string $dbname : Database Name chosen by the user on script install form.

function dbuser()

// Return the DBUSERNAME as per the panel
// e.g if dbusername is given and a prefix is required then please give it here
function dbuser($dbuser){
return $dbuser;
}

If the panel requires to modify the Database USER NAME that is to be created when installing a script, it has to be done here. Many panels e.g. cPanel accept input from users as DBUSERNAME but create Databases like USERNAME_DBUSERNAME. In such a case this function must return USERNAME_DBUSERNAME or DBUSERNAME

Parameter :

string $dbuser : Database Name chosen by the user on script install form (we use the database username the same as the database name chosen by user).

$this->myquery IS JUST AN EXAMPLE. You can create your own functions and use it in the class.

This function should delete the DATABASE and also the Database USER.

Parameters passed :

string $dbname - This is the value that is returned by function dbname()

string $dbuser - This is the value that is returned by function dbuser()

function spaceremain()

//Shows the Disk Space Available
function spaceremain(){
// Note: 1) Should be in BYTES
// 2) If it is not numeric then SOFTACULOUS will assume as UNLIMITED space
$space = (1024*1024*1024); // e.g. of a GB
return $space;
}

Should return the space available in BYTES. If a string is returned it will be assumed that the user has unlimited space remaining.

function delcron()

// Deletes a CRON JOB as per the command given
function delcron($command){
return true;
}

Delete a CRON job of a installation.

Parameters passed :

$command - The CRON Command itself. You will have to search and delete the cron job accordingly.

function blacklist_domains() (Optional)

This function is optional.
Choose list of domains you want to exclude for the user from existing list of domains owned by that user. Return array list of domains you want to blacklist with domain name as the key

function listcpplans() (Optional)

This function is optional.
You can use this function to pass a list of plans by fetching it from your control panel. Once you pass the control panel plans here you will be able to create an ACL for users from Softaculous Admin panel -> Plans and assign scripts to the user as per the plan he is under.
Return array list of control panel plans

function listcpplans(){
$cpplans = array();
return $cpplans;
}

User Management

Types of Users

There are three types of Users in Softaculous Enterprise :

Admin User

There is only one Admin User i.e root and is added by default during the installation.

Owner and Username of Admin User is root

It is responsible for handling the scripts, users, domains and other settings.

Admin can create Reseller as well as Regular Users.

Like Regular users even Admins can use the Enduser Panel and install scripts.

Reseller User

Only Admin can create Resellers.

Resellers can be added from Admin Panel only.

Number of users allotted to Reseller should be more by one because reseller himself is counted as a user. E.g If Admin has allotted 10 number of users then Reseller can add total 9 Regular Users under his account.

Resellers can create Regular Users.

Like Regular users even Resellers can use the Enduser Panel and install, remove and manage scripts.

If the Reseller is 'xyz' then the owner and the username of his accounts will be 'xyz'.

Regular User

Regular Users can be created by Admin or Resellers.

Owner of the Regular User will the User who is creating the user, it can be Admin(root) or Reseller.

They can install, remove, update, manage scripts from Enduser Panel.

The owner and the username of the Regular users create by a Reseller will be :

Owner => Reseller's Username(xyz in above example)

Username => User name of the regular user just created

The owner and the username of the Regular users create by Admin will be :

Owner => root

Username => User name of the regular user just created

Authentication Methods

There are three possible ways to login into Softaculous Enterprise :

Default Login

Access your server through browser <your-server-ip> or <your-domain>

Enter the API KEY and API PASS provided by the Softaculous Installer or your host to login into Softaculous Enterprise.

Login Code

This is optional part and Softaculous will use the default session handling.

Softaculous allows you to dynamically handle the session and define the User details and Domains to be listed under the user. This can be done using session.php where you can communicate with your control panel and validate the current user's session.

If session.php is created Softaculous will skip the authentication part and will assume that the session is authenticated by you.

You can define the user details i.e. username, owner, email and the domains owned by the current logged in user in $PRE_LOGIN array.

When Softaculous is loaded it will add the user and domains defined in $PRE_LOGIN if it does not exist in Softaculous database.

You can refer to the session.sample.php located at /usr/local/softaculous/enduser/session.sample.php

Variable

Example

Description

$PRE_LOGIN['username']

test

Username who will be accessing Softaculous Enterprise. Admin user is root which is created during installation time. If the username passed here does not exist in Softaculous Enterprise database it will be added.

$PRE_LOGIN['owner'] (Optional)

root

Owner who will own this account. This is not the username but this is the user who will own the account. If not specified 'root' will be assumed. Default owner is root which is created during installation time.

$PRE_LOGIN['email']

user@email.com

Email of the username. This is used to send emails like whether Install, Remove, Update of Scripts were successful or not.

$PRE_LOGIN['plan'] (Optional)

platinum

This is used to specify which control panel plan does this user falls under. Refer [[1]] for defining control panel plans

$PRE_LOGIN['uid']

505

UID is used to chown the directory of the installations of scripts installed by Softaculous. This is required to set the proper permission of the files/folder while installing, updating, the scripts.

$PRE_LOGIN['gid'] (Optional)

505

GID of the username. If not specified GID's value will be assumed same as UID's value. This is required to set the proper permission of the files/folder while installing, updating, the scripts.

$PRE_LOGIN['domains'][0]['domain']

domain.com

Domain Name where the users will be installing the scripts

$PRE_LOGIN['domains'][0]['path']

/NFS/a/var/www/html

Full path of the web accessible directory.

$PRE_LOGIN['domains'][0]['backupdir']

/NFS/a/var/www

Full Path of the Backup Directory. Backups created by Softaculous will be located here.

$PRE_LOGIN['domains'][0]['replace_path']

/NFS/a

This "Replace Path" will be replaced with empty in PATH to get the correct path according to scripts. According to the scripts PATH mentioned above is not correct as we are on NFS. We have to generate a new path with respect to scripts.

Sync Domains

When the domains are passed using $PRE_LOGIN['domains'] array described in the previous section the domain is synced with the Softaculous Enterprise database and if the domain does not exist in Softaculous Enterprise database the domain is added automatically.

However if you remove a domain from the $PRE_LOGIN['domains'] array it will not be deleted from Softaculous Enterprise database. In order to delete the domains when they are not passed in $PRE_LOGIN['domains'] you will need to enable the Enable Sync Domain(s) from Softaculous Admin Panel -> Settings page. Once this setting is enabled the domains passed in $PRE_LOGIN['domains'] will be in sync with the database and only the domains passed in $PRE_LOGIN['domains'] will be present in the database.

Session Tokens

Refer to Session Tokens for creating session tokens which can be used to redirect the user to Softaculous Enterprise with the session created. The user will not have to do anything to login in this method as the session is created by the Admin here for automation purposes.

How to use Softaculous Enterprise

To access Enduser Panel visit http://<your-ip> or http://<your-domain> and (Port 443 for HTTPS)

Get Script Info

The value should be "installations" to perform the action of listing installations.

soft

26 (26 is the Script ID of WordPress)

The value should be "SID" for softaculous to perform the action of installing a software. You can find the list of sid's here

giveinfo

1

Pass this value as 1 to get the information of the script (passed in the soft parameter)

Example

// The URL
$url = 'http://your.softaculous.com/index.php?'.
'api_key=TESTAPIKEY'.
'&api_pass=PASSPASSPASSPASSPASSPASSPASSPASS'.
'&api=serialize'.
'&act=software'.
'&soft=26'.
'&giveinfo=1';
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $time);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method. In this case its PHP Serialize
$res = unserialize($resp);
print_r($res);
print_r($res['info']['overview']); // will have overview of the script (in HTML format)
print_r($res['info']['features']); // will have features list of the script (in HTML format)
print_r($res['info']['demo']); // will have the link to demo of the script
print_r($res['info']['ratings']); // will have the link to ratings page of the script
print_r($res['info']['support']); // will have the link to script vendor support page
print_r($res['info']['release_date']); // will have the release date of the current version of the script
print_r($res['settings']); // will have an array of the list of fields that the script will require, e.g. site_name, site_desc, language, etc
print_r($res['dbtype']); // if the value is not empty it means the script requires a database, if the value is empty it means that the script does not require a database
print_r($res['cron']); // if the value is not empty it means the script requires a CRON JOB, if the value is empty it means that the script does not require a CRON JOB
print_r($res['datadir']); // if the value is not empty it means the script requires a data directory, if the value is empty it means that the script does not require a data directory

(Optional) - Location id of the backup location where you want to store your current backup. Default value will be the one saved in the installation's settings. You can find the location id from List Backup Locations

noemail

1

(Optional) - Use this only if you do not want to send an email to the user

This will trigger the only_realversion function to list only installations in which the version in Softaculous records do not match with actual installation version

list

array('username-26_68351', 'username-26_68352')

This will contain the array list for the installations which needs to be updated in Softaculous record(you will need to pass installation id which you will get from Real Version response in List Real Version

(Optional) Use this only if you want to add a reseller to the plan. resellers_ is the prefix for adding a reseller and abc is the name of the reseller (that should already exist). Similarly pass a separate key for each reseller you want to add to the plan.

users_xyz

1

(Optional) Use this only if you want to add a user to the plan. users_ is the prefix for adding a user and xyz is the name of the user (that should already exist). Similarly pass a separate key for each user you want to add to the plan.

scripts_26

1

Use this to pass the scripts to be added to the plan. scripts_ is the prefix for adding a script and 26 is the id of the script to be added. Similarly pass a separate key for each script you want to add to the plan. Get Script ids

(Optional) Use this only if you want to assign a reseller to the plan. resellers_ is the prefix for adding a reseller and abc is the name of the reseller (that should already exist). Similarly pass a separate key for each reseller you want to assign to the plan.

users_xyz

1

(Optional) Use this only if you want to assign a user to the plan. users_ is the prefix for assigning a user and xyz is the name of the user (that should already exist). Similarly pass a separate key for each user you want to assign to the plan.

scripts_413

1

Use this to pass the scripts to be assigned to the plan. scripts_ is the prefix for assigning a script and 26 is the id of the script to be assigned. Similarly pass a separate key for each script you want to assign to the plan. Get Script ids

Enable / Disable Script

This will trigger the submit function for enabling/disabling the scripts

soft_26

1

Use it to Enable Script from Admin Panel. soft_ is the prefix for enabling a script and 26 is the id of the script to be enabled. Similarly pass a separate key for each script you want to enable. Get Script ids

Note: If you have 10 scripts Enabled. You want to Enable 1 more script you will need to pass all 11 scripts id in the POST data for it to Enable the script. The scripts which are not posted will be disabled.

string $username User Name to addstring $email Email of the userstring $uid UID of the user$gid GID of the userstring $num_users (Optional) Number of Users a Reseller can add. Empty in case of Regular users.

Switch User

This function is only for API. This function helps you to switch between the users.

Suppose you are a Admin and if you want to install a script for a user. You can login from your own details and use this function in between to switch to your user.

Only Admins and Resellers can use this function.

Parameters :

$username The username for the user the Admin/Reseller want to switch to.

$owner The owner who owns the account of user. By default it is root.

Return Values : NULL

Example

In the following example root is logged in first with its API_KEY and API_PASS, then he switches to user abc. After switching, wordpress is installed as the user abc. Install function is explained in Softaculous SDK.
Similarly Admin/Reseller can perform tasks on behalf of their users.Note : Once you have switched to the user level then you cannot switch back to Admin/Reseller. You will have to login again.

$path is the web accessible folder/path where your installations will be made. It should be accessible by Softaculous over NFS. Web accessible directory should be owned by user specified. e.g '/NFS/a/home/user/public_html'

$backup_dir is the Backup Directory. Softaculous will create backups in this folder. This should be accessible by Softaculous over NFS.

e.g '/NFS/a/home/user/backups'

$replace_path This "Replace Path" will be replaced with empty in PATH to get the correct path according to scripts. According to the scripts PATH mentioned above is not correct as we are on NFS. We have to generate a new path with respect to scripts.

e.g Wordpress needs to be installed on /var/www/html/wp on a server. On NFS for Softaculous /var/www/html is mounted at a directory say /NFS/a/var/www/html. So now for Softaculous, wordpress path is /NFS/a/var/www/html/wp. But Softaculous requires /var/www/html/wp so /NFS/a/var/www/html/wp is converted to /var/www/html/wp by removing /NFS/a. Here /NFS/a is Replace Path.

$data_dir Full path of the Data Directory. Some scripts like Elgg, Moodle, etc need a non web accessible folder. Specify accordingly that it can be accessed by Softaculous too which is on NFS.

Return Values :

Result will be in array.

The result is stored in $result and if the domain was added successfully,