Skip to Content About Archive Belief Contact Pudding Search


tying a custom sytem into plesk


Sunday, July 29, 2007

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

ok well after stayng up for most of this weekend i’m still gonna end up having to use what i already had yesterday. but maybe my time wasted can help someone out there.

1. plesk’s cmd line subdomain creator does not tie into dns. so after slaving to have everything work perfectly with plesk - this is just another hill to conquer.

2. with the default mysql / plesk setup you have to use grant to add a user

3. there are there tables in the psa database that contain the info needed to display a subdomain in a users subdomain panel.

heres the code that finally worked for me


function processOnServer($clientName){
global $baseDir;
//make our password using the user name and adding some md5 salt to the tail
//each password must be unique, as it's how we'll find the ids later
$pass=md5($clientName);
$passLen=13-strlen($clientName);
$passEnd=substr($pass,0,$passLen);
$password=$clientName.$passEnd;
//setup the client dir location
$clientDir=$baseDir.$clientName;

$dbConn = mysql_connect('db_server', 'user', 'pass');
if (!$dbConn) {
die('Could not connect: ' . mysql_error());
}

$dbName=$clientName."_trac";
//create db
$sql = "CREATE DATABASE $dbName";
mysql_query($sql, $dbConn);

//select mysql db
mysql_select_db("mysql",$dbConn);
//add client user
$sql="GRANT ALL ON $dbName.* TO '$clientName' IDENTIFIED BY '$password'";
mysql_query($sql, $dbConn);
//select plesk db
/*plesk configuration - i'm leaving this till another day
mysql_select_db("psa",$dbConn);
//add account
$sql="INSERT INTO `accounts` (`id`, `type`, `password`) VALUES (NULL, 'plain', '$password')";
mysql_query($sql, $dbConn);
///find the new users id
$sql="SELECT id,password FROM accounts WHERE password = '$password' ORDER BY id DESC";
$findAccountId=mysql_query($sql, $dbConn);
list($newId) = mysql_fetch_row($findAccountId);

//add user to plesk for subdomain
$sql="INSERT INTO `sys_users` (`id`, `login`, `account_id`, `home`, `shell`, `quota`) VALUES (NULL, '$clientName', $newId, '$clientDir', '/bin/false', 0)";
mysql_query($sql, $dbConn);
//find the new new id
$sql="SELECT id,account_id FROM sys_users WHERE account_id=$newId ORDER BY id DESC";
$findAccountId2=mysql_query($sql, $dbConn);
list($newerId) = mysql_fetch_row($findAccountId2);

//add subdomain to plesk
$sql="INSERT INTO `subdomains` (`id`, `dom_id`, `name`, `displayName`, `sys_user_type`, `sys_user_id`, `ssi`, `php`, `cgi`, `perl`, `python`, `fastcgi`, `miva`, `coldfusion`, `asp`, `asp_dot_net`, `ssl`, `same_ssl`) VALUES (NULL, 1, '$clientName', '$clientName', 'native', $newerId, 'false', 'true', 'false', 'false', 'false', 'false', 'false', 'false', 'false', 'false', 'true', 'false')";
mysql_query($sql, $dbConn) or die('Could not connect: ' . mysql_error());
*/
//make config file
$fileName = md5($clientName);
makeApacheFiles($clientName,$fileName.".conf");
makeTracFiles($clientName,$fileName.".ini",$password);
makeAuthFiles($clientName,$fileName.".authz");

//finish the svn and trac setup
passthru("shell_script $clientName $password $fileName");

}

the codes choppy (i’ve been up for over 30 hours - so i’m sure it looks worse to use :) )

the system i’ve built uses a custom frontend app to create, manage subdomains, and do automated installs of svn repos / trac, etc.

if you look over that code you’ll see there’s three psa tables that need fixing to allow your client to also view your subdomains in plesk.

also the ftp fix mentioned on there site won’t work on mediatemple. when i find one i’ll post it.

in addtional to all this. the psa database is only a place holder for the frontend, and in no way reflects the actually server (unless you do everything from plesk)

if you add a db or a dns record you’ll have to also update the psa db.

don’t know if i’m still making sense, off to bed - sid

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
Might Be Related

2 Responses to “tying a custom sytem into plesk”


  1. collector Says:

    So databases and subdomains сreated using command line will not be visible in control panel? Is it correct?


    View this Comment in: English Chinese(S) Chinese(T) French Arabic Dutch German Greek Italian Japanese Korean Portuguese Russian Spanish

  2. admin Says:

    yes


    View this Comment in: English Chinese(S) Chinese(T) French Arabic Dutch German Greek Italian Japanese Korean Portuguese Russian Spanish

Leave a Reply


In order to submit a comment, you need to mention your name and your email address (which won't be published). And ... don't forget your comment!

Comment Form