Formatting code for MultipleDatabases
[[PhplistHacks phplist Hacks]]
----
====Multiple Databases====
==What==
Multiple phplist installations running on one file setup and multiple databases
==When==
If you're hosting several installations on one machine (possibly for several clients, or several websites) but you want to save setup and maintenance time or simply disk space.
The following was tested on phplist-2.8.12 but it should work on any phplist version I am aware of, since PHPList has stored all its settings in config.php for quite some time now.
===Method 1: Using an environment variable pointing to the config file===
-copy ##config.php## from original source (preferably somewhere outside your webserver document root) and configure as required
-set up database for individual installation/list as normal
-use:
%%SetEnv ConfigFile /path/to/config/file%%
in your host, ##vhost## or ##.htaccess## file
-setup url for list access. This can be done by either:
1. using aliases in your apache conf file (or configuration interface)
%%alias /mailinglist/ /var/www/phplist/install/directory/public_html/lists/%%
2. using Apache virtual domains in your apache conf file (or configuration interface)
%%ServerName mailinglist.sitename.com
DocumentRoot /var/www/phplist/install/directory/public_html/lists/%%
===Method 2: deciding in your config.php file, depending on the host or url served, what config file to include===
-save original ##config.php## as
~-config.setup1.php
~-config.setup2.php
~- ...
-setup url for list access. This can be done by either:
~1. using aliases in your apache conf file (or configuration interface)
%%alias /mailinglist /var/www/phplist/install/directory/public_html/lists/%%
~~then you'll have something like this in your config.php:
%%(php) eregi ( "/([a-z0-9_-]{1,})/(.*)", $_SERVER ['REQUEST_URI'], $regs);
$liste = $regs[1];
switch ($liste){
case "mailinglist1":
include_once("config.setup1.php");
break;
case "mailinglist2":
include_once("config.setup2.php");
break;
default:
die ("this directory not used to run phplist");
}
?>%%
~2. using Apache virtual domains in your apache conf file (or configuration interface)
%%ServerName mailinglist.sitename.com
DocumentRoot /var/www/phplist/install/directory/public_html/lists/%%
~~then you'll have something like this in your config.php:
%%(php) switch ($_SERVER [ 'SERVER_NAME' ])
{
case "setup1.com":
include_once("config.setup1.php");
break;
case "setup2.com":
include_once("config.setup2.php");
break;
default:
die ("server not used to run phplist");
}
?>%%
----
CategoryHacks
----
====Multiple Databases====
==What==
Multiple phplist installations running on one file setup and multiple databases
==When==
If you're hosting several installations on one machine (possibly for several clients, or several websites) but you want to save setup and maintenance time or simply disk space.
The following was tested on phplist-2.8.12 but it should work on any phplist version I am aware of, since PHPList has stored all its settings in config.php for quite some time now.
===Method 1: Using an environment variable pointing to the config file===
-copy ##config.php## from original source (preferably somewhere outside your webserver document root) and configure as required
-set up database for individual installation/list as normal
-use:
%%SetEnv ConfigFile /path/to/config/file%%
in your host, ##vhost## or ##.htaccess## file
-setup url for list access. This can be done by either:
1. using aliases in your apache conf file (or configuration interface)
%%alias /mailinglist/ /var/www/phplist/install/directory/public_html/lists/%%
2. using Apache virtual domains in your apache conf file (or configuration interface)
%%ServerName mailinglist.sitename.com
DocumentRoot /var/www/phplist/install/directory/public_html/lists/%%
===Method 2: deciding in your config.php file, depending on the host or url served, what config file to include===
-save original ##config.php## as
~-config.setup1.php
~-config.setup2.php
~- ...
-setup url for list access. This can be done by either:
~1. using aliases in your apache conf file (or configuration interface)
%%alias /mailinglist /var/www/phplist/install/directory/public_html/lists/%%
~~then you'll have something like this in your config.php:
%%(php) eregi ( "/([a-z0-9_-]{1,})/(.*)", $_SERVER ['REQUEST_URI'], $regs);
$liste = $regs[1];
switch ($liste){
case "mailinglist1":
include_once("config.setup1.php");
break;
case "mailinglist2":
include_once("config.setup2.php");
break;
default:
die ("this directory not used to run phplist");
}
?>%%
~2. using Apache virtual domains in your apache conf file (or configuration interface)
%%ServerName mailinglist.sitename.com
DocumentRoot /var/www/phplist/install/directory/public_html/lists/%%
~~then you'll have something like this in your config.php:
%%(php) switch ($_SERVER [ 'SERVER_NAME' ])
{
case "setup1.com":
include_once("config.setup1.php");
break;
case "setup2.com":
include_once("config.setup2.php");
break;
default:
die ("server not used to run phplist");
}
?>%%
----
CategoryHacks



