Installazione Multitenant di PhpList

From RVM Wiki
Jump to navigation Jump to search
  • Una sola installazione di Phplist può esere utilizzata per gestire più databsses e configurazioni separate
  • Si vuole impostare una gestione del tipo
https://mailing.example.com/customer1
https://mailing.example.com/customer2
  • Creare il master config.php
sudoedit config/config.php
<?php
eregi ( "/([a-z0-9_-]{1,})/(.*)", $_SERVER ['REQUEST_URI'], $regs);
$liste = $regs[1];
switch ($liste){
    case "customer1":
    	include_once("config.customer1.php");
    	break;

    case "customer2":
    	include_once("config.customer2.php");
    	break;
   
    break;
   
    default:
	    die ("This directory not used to run phplist"); 
}

?>
  • Creare i config dei due customers, prendendo il template ed inserendo i dati del DB di ciscuno:
sudo cp config_extended.php config.customer1.php
sudo cp config_extended.php config.customer2.php
sudoedit  config.customer1.php
sudoedit  config.customer2.php
  • Modificare la definizione del virtualhost apache:
sudoedit mailing.example.com
# ...
    DocumentRoot /var/www/mailing.example.com/html

    Alias /customer1  /var/www/mailing.example.com/html
    Alias /customer2  /var/www/mailing.example.com/html
#...
  • Accedere agli url, e procedere con la configurazione
  • Ricordarsi di impostare il crontab per la gestione della coda come
sudoedit /etc/cron.d/process-phplist
#=================================================================
# CRON JOB FOR COMMAND LINE SCRIPT "phplist"
# (PHP-cli required)
# My config.php file has:
#   $commandline_users = array("user1","user2","user3");
#   define("MAILQUEUE_BATCH_SIZE",200);
#   define("MAILQUEUE_BATCH_PERIOD",3600);
#   define('MAILQUEUE_THROTTLE',5);
#
#  Every hour at 15 minutes past, we process the queued messages.
#  Every day at 1.10 am, we process bounces.
#=================================================================
MAILTO="listreports@rvmgroup.it"
USER="www-data"
PHPLISTPATH="/var/www/mailing.example.com"

#m      h       dom     mon     dow     user            command
*/10    *       *               *               *               www-data      $PHPLISTPATH/phplist-cron -pprocessqueue > /dev/null
10      1       *               *               *               www-data       $PHPLISTPATH/phplist-cron -pprocessbounces > /dev/null

  • Lo script sarà
sudoedit /var/www/mailing.example.com/phplist-cron
#!/bin/bash

# script to run PHPlist from commandline. You may need to edit this to make it
# work with your shell environment. The following should work for Bash on
# Fedora Linux but this may vary strongly in other situations. You will need to
# dig into the code to make sure it works for you.

# in commandline mode, access is restricted to users who are listed in the
# config file check README.commandline for more info

# identify the config file for your installation
for CFG in customer1 customer2
do
	PHPLISTPATH="/var/www/mailing.example.com"
	CONFIG="${PHPLISTPATH}/config/config.${CFG}.php"
	export CONFIG

	# alternatively you can use -c <path to config file> on the commandline

	# run the PHPlist index file with all parameters passed to this script
	/usr/bin/php ${PHPLISTPATH}/admin/index.php -c $CONFIG $*
done

Riferimenti