Z-Push

De Wiki iRENALA

Description du serveur

  • OS: CentOS 7.1 x86_64
  • Zimbra: 8.6.0 GA OSE

Installation de Z-Push

  • Téléchargement de Z-Push et de son Backend:
cd /opt/
wget http://download.z-push.org/final/2.2/z-push-2.2.7.tar.gz
tar -xvf z-push-2.2.7.tar.gz
mv z-push-2.2.7 z-push
cd /opt/z-push/backend/
wget http://downloads.sourceforge.net/project/zimbrabackend/Release63/zimbra63.tgz
tar -xvf zimbra63.tgz
mv /opt/z-push/backend/zimbra63/z-push-2/ /opt/z-push/backend/zimbra
rm -rf opt/z-push/backend/zimbra63*
  • Création des répertoires requis:
mkdir /opt/z-push/log
mkdir /opt/z-push/state
chmod 777 /opt/z-push/log
chmod 777 /opt/z-push/state

Configuration de Z-Push

Fichier: /opt/z-push/config.php

  • Modifier les valeurs suivantes:
define('TIMEZONE', 'Europe/Paris');
define('STATE_DIR', '/opt/z-push/state/');
define('LOGFILEDIR', '/opt/z-push/log/');
define('SYNC_FILTERTIME_MAX', SYNC_FILTERTYPE_ALL);
define('BACKEND_PROVIDER', 'BackendZimbra');
define('PROVISIONING', false);
  • Ajouter les valeurs suivantes:
 define('ZIMBRA_URL', 'https://mail.irenala.edu.mg');
 define('ZIMBRA_USER_DIR', 'zimbra');
 define('ZIMBRA_SYNC_CONTACT_PICTURES', true);
 define('ZIMBRA_VIRTUAL_CONTACTS',true);
 define('ZIMBRA_VIRTUAL_APPOINTMENTS',true);
 define('ZIMBRA_VIRTUAL_TASKS',true);
 define('ZIMBRA_IGNORE_EMAILED_CONTACTS',true);
 define('ZIMBRA_HTML',false);
 define('ZIMBRA_ENFORCE_VALID_EMAIL',true);

 //=== Optional ===
 define('ZIMBRA_NOKIA_MFE_FIX',true);
 define('ZIMBRA_NOKIA_MFE_ALWAYS_OVERWRITE',true); 

REMARQUE: Commenter les lignes 59, 60, 61, 62, 63, 64, 65, 66, 72 du fichier /opt/z-push/backend/zimbra/config.php pour avoir des logs compréhensibles

Configuration de Jetty

Prérequis

Installation des prérequis:

yum install php-cli php-process

Création du wraper PHP

Fichier: /usr/bin/php-cgi-fix.sh

#/usr/bin/sh
export SCRIPT_FILENAME=$1
/usr/bin/php-cgi

Modification de la class Microsoft-Server-ActiveSync

Fichier: /opt/zimbra/jetty/etc/jetty.xml.in

  • Chercher:
/service/extension/zimbrasync
  • Remplacer par:
/z-push/index.php

Déclaration du nouveau WEBAPP Z-Push

Fichier: /opt/zimbra/jetty/etc/jetty.xml.in

Etape #1

  • Chercher:
<Call name="addRule">
   <Arg>
       <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
           <Set name="pattern">/zimlet/*</Set>
           <Set name="replacement">/zimlet</Set>
           <Set name="terminating">true</Set>
       </New>
   </Arg>
</Call>
  • Ajouter après:
<Call name="addRule">
   <Arg>
       <New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
           <Set name="pattern">/z-push/*</Set>
           <Set name="replacement">/z-push</Set>
           <Set name="terminating">true</Set>
       </New>
   </Arg>
</Call>

Etape #2

  • Chercher:
<New id="zimlet" class="org.eclipse.jetty.webapp.WebAppContext">
   <Arg><Ref id="Contexts"/></Arg>
   <Arg><SystemProperty name="jetty.home" default="."/>/webapps/zimlet</Arg>
   <Arg>/zimlet</Arg>
   <Set name="configurationClasses"><Ref id="plusConfig"/></Set>
   <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
   <Set name="tempDirectory"><SystemProperty name="jetty.home" default="."/>/work/zimlet</Set>
   <Set name="compactPath">true</Set>
   <Set name="throwUnavailableOnStartupException">true</Set>
   <Set name="baseResource">
       <New class="org.eclipse.jetty.util.resource.ResourceCollection">
           <Arg>
               <Array type="String">
                   <Item><SystemProperty name="jetty.home" default="."/>/webapps/zimlet</Item>
                   <Item><SystemProperty name="jetty.home" default="."/>/../zimlets-deployed</Item>
               </Array>
           </Arg>
       </New>
   </Set>
   <Call name="setAttribute">
       <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
       <Arg>.*/.*jsp-api-[^/]*.jar$|.*/.*jsp-[^/]*.jar$|.*/.*taglibs[^/]*.jar$</Arg>
   </Call>
</New>
  • Ajouter après:
<New id="z-push" class="org.eclipse.jetty.webapp.WebAppContext">
  <Arg><Ref id="Contexts"/></Arg>
  <Arg><SystemProperty name="jetty.home" default="."/>/webapps/z-push</Arg>
  <Arg>/z-push</Arg>
  <Set name="configurationClasses"><Ref id="plusConfig"/></Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
  <Set name="tempDirectory"><SystemProperty name="jetty.home" default="."/>/work/z-push</Set>
  <Set name="compactPath">true</Set>
  <Get name="errorHandler">
    <Call name="setShowStacks">
      <Arg type="boolean">false</Arg>
    </Call>
  </Get>
  <Call name="setAttribute">
    <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
            <Arg>.*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$</Arg>
  </Call>
</New>

Etape #3

Création de la liaison entre Z-Push et Zimbra:

ln -s /opt/z-push/ /opt/zimbra/jetty/webapps/

Etape #4

Rajouter au fichier: /etc/php.ini

magic_quotes_gpc off
register_globals off
magic_quotes_runtime off
short_open_tag on
cgi.force_redirect = 0
max_execution_time = 120
memory_limit = 128M

Création du fichier de config Z-Push pour Jetty

  • Fichier: /opt/z-push/WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
      version="2.4"
    >

     <display-name>php</display-name>

     <servlet>
       <servlet-name>PHP</servlet-name>
       <servlet-class>org.eclipse.jetty.servlets.CGI</servlet-class>
       <load-on-startup>1</load-on-startup>

       <init-param>
            <param-name>commandPrefix</param-name>
            <param-value>/usr/bin/php-cgi-fix.sh</param-value>
       </init-param>

          <init-param>
              <param-name>Path</param-name>
              <param-value>/bin:/usr/bin:/usr/local/bin</param-value>
          </init-param>
        <async-supported>true</async-supported>
     </servlet>

     <servlet-mapping>
       <servlet-name>PHP</servlet-name>
       <url-pattern>*.php</url-pattern>
     </servlet-mapping>

     <!--
     <welcome-file-list>
       <welcome-file>index.php</welcome-file>
     </welcome-file-list>
     -->

     <Call name="addAliasCheck">
       <Arg>
         <New class="org.eclipse.jetty.server.handler.ContextHandler$ApprovePathPrefixAliases"/>
       </Arg>
     </Call>

     <security-constraint>
           <web-resource-collection>
               <web-resource-name>deny</web-resource-name>
               <url-pattern>/backend/*</url-pattern>
               <url-pattern>/include/*</url-pattern>
               <url-pattern>/lib/*</url-pattern>
               <url-pattern>/WEB-INF/*</url-pattern>
               <url-pattern>/config.php</url-pattern>
               <url-pattern>/z-push-top.php</url-pattern>
               <url-pattern>/z-push-admin.php</url-pattern>
               <url-pattern>/INSTALL</url-pattern>
               <url-pattern>/LICENSE</url-pattern>
           </web-resource-collection>
           <auth-constraint>
          <role-name>deny</role-name>
           </auth-constraint>
     </security-constraint>
    </web-app>
  • Redémarrage de Zimbra:
su - zimbra -c "zmcontrol restart"