This topic is locked
[SOLVED]

 Optimization of several installations via symlinks and cdn

1/7/2018 9:10:38 AM
PHPRunner General questions
mbintex author

Hi all,
still looking for ways to optimize the deployment of several installations on one server for different customers (software as a service).
Currently I have for example 60 customers using one solution, each customer has his own database and php solution file sets.
With that you get x installations of plugins like ckeditor, use a lot of space for installing dompdf x times and so forth.
So I ask myself if all this could be optimized for

  • saving space on the server
  • speeding up installation for new customers
  • ease updates


by using CDNs (https://cdnjs.com/) or symlinks on my server.
Has anyone done this and experience with this? I had a quick try with a symlink to a centralized installation of ckeditor and that didn´t work.

admin 1/8/2018

This is the wrong way to implement SAAS. You should have just one copy of the software and let each customer connect to their own database. This is what everyone else does.

mbintex author 1/8/2018

And what´s the best practise to do that with PHPrunner? Any link, doc, howto for that?

admin 1/8/2018

You can get some ideas here:

http://asprunner.com/forums/topic/22343-how-to-make-single-project-connect-to-different-databases-passing-database-name-via-url/
Apparently a better option is to have a subdomain for each client i.e. client1.website.com, client2.website.com etc.

mbintex author 1/8/2018

Hi Admin,
trying to follow your advice.
I changed my "Server database connections" script in Output Directory screen to this:

$dbname=$_GET["dbname"];
if($dbname=="standard")

{

$sys_dbname="DATABASE1";

$user="USER1";

$pwd="PASSW1";

}

elseif($dbname=="customer")

{

$sys_dbname="DATABASE2";

$user="USER2";

$pwd="PASSW2";

}

elseif($dbname=="demo")

{

$sys_dbname="DATABASE3";

$user="USER3";

$pwd="PASSW3";

}
$host="intex-publishing.de";

$port="";
$_SESSION["host"]=$host;

$_SESSION["user"]=$user;

$_SESSION["pwd"]=$pwd;

$_SESSION["dbname"]=$sys_dbname;


The login screen appears after I have opened a url like
https://www.test.de/databases/login.php?dbname=standard
But when I fill in the fitting credentials for any of the database I get:
Fatal error: Access denied for user ''@'99.99.999.999' (using password: NO) in /www/htdocs/.../connections/Connection.php on line 661
Would be great if you have any advice, since this solution path for my problem would be a real breakthrough for me.

mbintex author 1/8/2018

Changing my script to

if($_GET["dbname"])

$_SESSION["db"]=$_GET["dbname"];
if($_SESSION["db"]=="standard")

{

$sys_dbname="DATABASE1";

$user="USER1";

$pwd="PASSW1";
}

elseif($_SESSION["db"]=="customer")

{

$sys_dbname="DATABASE2";

$user="USER2";

$pwd="PASSW2";
}

elseif($_SESSION["db"]=="demo")

{

$sys_dbname="DATABASE3";

$user="USER3";

$pwd="PASSW3";2";
}

else

{

$sys_dbname="DATABASE1";

$user="USER1";

$pwd="PASSW1";
}
$host="intex-publishing.de";

$port="";
$_SESSION["host"]=$host;

$_SESSION["user"]=$user;

$_SESSION["pwd"]=$pwd;

$_SESSION["dbname"]=$sys_dbname;


seems to do the job :-)
One installation and endless possible databases/customers ...

mbintex author 1/9/2018

It gets even better if you take into consideration, that this way one can now offer an auto-update mechanism.
Simple steps:

  • have a revision field in your database with a number
  • after successful login query this field for the revisionnumber in the database
  • have update-SQL-queries defining new tables and fields, adding standard data for example for value lists, changing fields
  • set the revisionnumber one higher
    This way the user updates his database automatically when logging in :-)