function build() { $unix = new unix(); $sock = new sockets(); $users = new usersMenus(); $APACHE_MODULES_PATH = $users->APACHE_MODULES_PATH; if ($GLOBALS["OUTPUT"]) { echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Apache modules in \"{$APACHE_MODULES_PATH}\"\n"; } $ZarafaApachePort = $sock->GET_INFO("ZarafaApachePort"); $ZarafaApacheSSL = $sock->GET_INFO("ZarafaApacheSSL"); $LighttpdArticaDisableSSLv2 = $sock->GET_INFO("LighttpdArticaDisableSSLv2"); $ZarafaWebNTLM = $sock->GET_INFO("ZarafaWebNTLM"); $ZarafaApacheServerName = $sock->GET_INFO("ZarafaApacheServerName"); if (!is_numeric($ZarafaWebNTLM)) { $ZarafaWebNTLM = 0; } if (!is_numeric($LighttpdArticaDisableSSLv2)) { $LighttpdArticaDisableSSLv2 = 0; } if (!is_numeric($ZarafaApacheSSL)) { $ZarafaApacheSSL = 0; } if (!is_numeric($ZarafaApachePort)) { $ZarafaApachePort = 9010; } $ZarafaApachePHPFPMEnable = $sock->GET_INFO("ZarafaApachePHPFPMEnable"); if (!is_numeric($ZarafaApachePHPFPMEnable)) { $ZarafaApachePHPFPMEnable = 0; } if ($ZarafaApacheServerName == null) { $ZarafaApacheServerName = $unix->hostname_g(); } if (!is_dir('/usr/share/php/mapi')) { if (is_dir('/usr/local/share/php/mapi')) { @mkdir("/usr/share/php", 0755, true); shell_exec('/bin/ln -s /usr/local/share/php/mapi /usr/share/php/mapi'); } } $username = $unix->APACHE_SRC_ACCOUNT(); $group = $unix->APACHE_SRC_GROUP(); if ($GLOBALS["OUTPUT"]) { echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} logs access: /var/log/apache-zarafa/access.log\n"; } if ($GLOBALS["OUTPUT"]) { echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} logs error : /var/log/apache-zarafa/error.log\n"; } @unlink("/var/log/apache-zarafa/access.log"); @unlink("/var/log/apache-zarafa/error.log"); @touch("/var/log/apache-zarafa/access.log"); @touch("/var/log/apache-zarafa/access.log"); @mkdir("/var/run/apache2", 0755, true); @mkdir("/var/run/artica-apache", 0755, true); @mkdir('/var/run/zarafa-web', 0755, true); @mkdir('/var/log/apache-zarafa', 0755, true); @mkdir('/var/lib/zarafa-webaccess/tmp', 0755, true); $unix->chown_func($username, $group, "/var/log/apache-zarafa/access.log"); $unix->chown_func($username, $group, "/var/log/apache-zarafa/error.log"); $unix->chown_func($username, $group, "/var/run/apache2"); $unix->chown_func($username, $group, "/var/run/artica-apache"); $unix->chown_func($username, $group, "/var/run/zarafa-web"); $unix->chown_func($username, $group, "/var/log/apache-zarafa"); $unix->chown_func($username, $group, "/var/lib/zarafa-webaccess"); $unix->chmod_func(0777, "/var/lib/zarafa-webaccess/tmp"); $unix->chown_func($username, $group, "/usr/share/zarafa-webaccess/plugins/*"); if ($ZarafaApacheSSL == 1) { if (is_file("{$APACHE_MODULES_PATH}/mod_ssl.so")) { if (!is_file("/etc/ssl/certs/zarafa/apache.crt.nopass.cert")) { shell_exec("/usr/share/artica-postfix/bin/artica-install --zarafa-apache-certificates"); } $f[] = "LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so"; $f[] = "SSLEngine on"; $f[] = "SSLCertificateFile /etc/ssl/certs/zarafa/apache.crt.nopass.cert"; $f[] = "SSLCertificateKeyFile /etc/ssl/certs/zarafa/apache-ca.key.nopass.key"; if ($LighttpdArticaDisableSSLv2 == 1) { $f[] = "SSLProtocol -ALL +SSLv3 +TLSv1"; $f[] = "SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"; } $f[] = "SSLRandomSeed connect builtin"; $f[] = "SSLRandomSeed startup file:/dev/urandom 256"; $f[] = "SSLRandomSeed connect file:/dev/urandom 256"; $f[] = "AddType application/x-x509-ca-cert .crt"; $f[] = "AddType application/x-pkcs7-crl .crl"; $f[] = "SSLPassPhraseDialog builtin"; $f[] = "SSLSessionCache shmcb:/var/run/apache2/ssl_scache-zarafa(512000)"; $f[] = "SSLSessionCacheTimeout 300"; $f[] = "SSLVerifyClient none"; $f[] = "ServerSignature Off"; } } $SET_MODULES = SET_MODULES(); $FreeWebPerformances = unserialize(base64_decode($sock->GET_INFO("ZarafaApachePerformances"))); if (!is_numeric($FreeWebPerformances["Timeout"])) { $FreeWebPerformances["Timeout"] = 300; } if (!is_numeric($FreeWebPerformances["KeepAlive"])) { $FreeWebPerformances["KeepAlive"] = 0; } if (!is_numeric($FreeWebPerformances["MaxKeepAliveRequests"])) { $FreeWebPerformances["MaxKeepAliveRequests"] = 100; } if (!is_numeric($FreeWebPerformances["KeepAliveTimeout"])) { $FreeWebPerformances["KeepAliveTimeout"] = 15; } if (!is_numeric($FreeWebPerformances["MinSpareServers"])) { $FreeWebPerformances["MinSpareServers"] = 5; } if (!is_numeric($FreeWebPerformances["MaxSpareServers"])) { $FreeWebPerformances["MaxSpareServers"] = 10; } if (!is_numeric($FreeWebPerformances["StartServers"])) { $FreeWebPerformances["StartServers"] = 5; } if (!is_numeric($FreeWebPerformances["MaxClients"])) { $FreeWebPerformances["MaxClients"] = 50; } if (!is_numeric($FreeWebPerformances["MaxRequestsPerChild"])) { $FreeWebPerformances["MaxRequestsPerChild"] = 10000; } $f[] = "Timeout {$FreeWebPerformances["Timeout"]}"; $f[] = "KeepAlive {$FreeWebPerformances["KeepAlive"]}"; $f[] = "KeepAliveTimeout {$FreeWebPerformances["KeepAliveTimeout"]}"; $f[] = "StartServers {$FreeWebPerformances["StartServers"]}"; $f[] = "MaxClients {$FreeWebPerformances["MaxClients"]}"; $f[] = "MinSpareServers {$FreeWebPerformances["MinSpareServers"]}"; $f[] = "MaxSpareServers {$FreeWebPerformances["MaxSpareServers"]}"; $f[] = "MaxRequestsPerChild {$FreeWebPerformances["MaxRequestsPerChild"]}"; $f[] = "MaxKeepAliveRequests {$FreeWebPerformances["MaxKeepAliveRequests"]}"; $f[] = "ServerLimit\t\t {$FreeWebPerformances["MaxClients"]}"; $f[] = "AcceptMutex \t\t flock"; $ZarafaApacheWebMailType = $sock->GET_INFO("ZarafaApacheWebMailType"); //$ZarafaApacheWebMailTypeA["APP_ZARAFA"]="{APP_ZARAFA}"; //$ZarafaApacheWebMailTypeA["APP_ZARAFA_WEBAPP"]="{APP_ZARAFA_WEBAPP}"; if ($ZarafaApacheWebMailType == null) { $ZarafaApacheWebMailType = "APP_ZARAFA"; } $f[] = $SET_MODULES; $f[] = "<IfModule !mpm_netware_module>"; $f[] = " <IfModule !mpm_winnt_module>"; $f[] = " User {$username}"; $f[] = " Group {$group}"; $f[] = " </IfModule>"; $f[] = "</IfModule>"; $f[] = "ServerAdmin you@example.com"; $f[] = "ServerName {$ZarafaApacheServerName}"; if ($ZarafaApacheWebMailType == "APP_ZARAFA_WEBAPP") { if (!is_dir("/usr/share/zarafa-webapp")) { $ZarafaApacheWebMailType = "APP_ZARAFA"; } } if ($ZarafaApacheWebMailType == "APP_ZARAFA") { $DocumentRoot = "/usr/share/zarafa-webaccess"; } if ($ZarafaApacheWebMailType == "APP_ZARAFA_WEBAPP") { $free = new freeweb(); $free->InstallZarafaConfigWebAPP("/usr/share/zarafa-webapp"); $DocumentRoot = "/usr/share/zarafa-webapp"; } if ($GLOBALS["OUTPUT"]) { echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} WebMail \"{$ZarafaApacheWebMailType}\"\n"; } $f[] = "ServerRoot \"{$DocumentRoot}\""; $f[] = "Listen {$ZarafaApachePort}"; $f[] = "User {$username}"; $f[] = "Group {$group}"; $f[] = "PidFile /var/run/zarafa-web/httpd.pid"; $f[] = "DocumentRoot \"{$DocumentRoot}\""; $f[] = "<Directory {$DocumentRoot}/>"; if ($ZarafaWebNTLM == 1) { $ldap = new clladp(); $f[] = " AuthName \"Zarafa logon..\""; $f[] = " AuthType Basic"; $f[] = " AuthLDAPURL ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/dc=organizations,{$ldap->suffix}?uid"; $f[] = " AuthLDAPBindDN cn={$ldap->ldap_admin},{$ldap->suffix}"; $f[] = " AuthLDAPBindPassword {$ldap->ldap_password}"; $f[] = " AuthLDAPGroupAttribute memberUid"; $f[] = " AuthBasicProvider ldap"; $f[] = " AuthzLDAPAuthoritative off"; $f[] = " require valid-user"; } if ($ZarafaApachePHPFPMEnable == 0) { $f[] = " php_value magic_quotes_gpc 0"; $f[] = " php_value register_globals 0"; $f[] = " php_value magic_quotes_runtime 0"; $f[] = " php_value post_max_size 31M"; $f[] = " php_value include_path \".:/usr/share/php:/usr/share/php5:/usr/local/share/php\""; $f[] = " php_value upload_max_filesize 30M"; $f[] = " php_value short_open_tag 1"; $f[] = " php_flag log_errors on"; $f[] = " php_value safe_mode 0"; $f[] = " php_flag log_errors on"; $f[] = " php_value error_log \"/var/log/apache-zarafa/php.log\""; } $f[] = " DirectoryIndex index.php"; $f[] = " Options -Indexes +FollowSymLinks"; $f[] = " AllowOverride Options"; $f[] = " Order allow,deny"; $f[] = " Allow from all"; $f[] = "</Directory>"; if ($ZarafaApachePHPFPMEnable == 1) { $php = $unix->LOCATE_PHP5_BIN(); if (!$unix->is_socket("/var/run/php-fpm-zarafa.sock")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: /var/run/php-fpm-zarafa.sock no such socket\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Activate PHP5-FPM\n"; } shell_exec("{$php} /usr/share/artica-postfix/exec.initslapd.php --phppfm"); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Restarting PHP5-FPM\n"; } shell_exec("/etc/init.d/php5-fpm restart"); } $f[] = "\tAlias /php5.fastcgi /var/run/artica-apache/php5.fastcgi"; $f[] = "\tAddHandler php-script .php"; $f[] = "\tFastCGIExternalServer /var/run/artica-apache/php5.fastcgi -socket /var/run/php-fpm-zarafa.sock -idle-timeout 610"; $f[] = "\tAction php-script /php5.fastcgi virtual"; $f[] = "\t<Directory /var/run/artica-apache>"; $f[] = "\t\t<Files php5.fastcgi>"; $f[] = "\t\tOrder deny,allow"; $f[] = "\t\tAllow from all"; $f[] = "\t\t</Files>"; $f[] = "\t</Directory>"; } else { if ($GLOBALS["OUTPUT"]) { echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP5-FPM is disabled\n"; } } $f[] = "<IfModule dir_module>"; $f[] = " DirectoryIndex index.php"; $f[] = "</IfModule>"; $f[] = ""; $f[] = ""; $f[] = "<FilesMatch \"^\\.ht\">"; $f[] = " Order allow,deny"; $f[] = " Deny from all"; $f[] = " Satisfy All"; $f[] = "</FilesMatch>"; $f[] = "<IfModule mod_php5.c>"; $f[] = " <FilesMatch \"\\.ph(p3?|tml)\$\">"; $f[] = "\tSetHandler application/x-httpd-php"; $f[] = " </FilesMatch>"; $f[] = " <FilesMatch \"\\.phps\$\">"; $f[] = "\tSetHandler application/x-httpd-php-source"; $f[] = " </FilesMatch>"; $f[] = " # To re-enable php in user directories comment the following lines"; $f[] = " # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it"; $f[] = " # prevents .htaccess files from disabling it."; $f[] = " <IfModule mod_userdir.c>"; $f[] = " <Directory /home/*/public_html>"; $f[] = " php_admin_value engine Off"; $f[] = " </Directory>"; $f[] = " </IfModule>"; $f[] = "</IfModule>"; $f[] = ""; $f[] = ""; $f[] = "ErrorLog \"/var/log/apache-zarafa/error.log\""; $f[] = "LogLevel warn"; $f[] = ""; $f[] = "<IfModule log_config_module>"; $f[] = " LogFormat \"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" %V\\\" combinedv"; $f[] = " LogFormat \"%h %l %u %t \\\"%r\\\" %>s %b\" common"; $f[] = ""; $f[] = " <IfModule logio_module>"; $f[] = " LogFormat \"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" %I %O\" combinedio"; $f[] = " </IfModule>"; $f[] = ""; $f[] = " CustomLog \"/var/log/apache-zarafa/access.log\" combinedv"; $f[] = "</IfModule>"; $f[] = ""; $f[] = "<IfModule alias_module>"; $f[] = " ScriptAlias /cgi-bin/ \"/usr/local/apache-groupware/data/cgi-bin/\""; $f[] = " Alias /images /usr/share/obm2/resources"; $f[] = ""; $f[] = "</IfModule>"; $f[] = ""; $f[] = "<IfModule cgid_module>"; $f[] = ""; $f[] = "</IfModule>"; $f[] = ""; $f[] = ""; $f[] = "<Directory \"/usr/local/apache-groupware/data/cgi-bin\">"; $f[] = " AllowOverride None"; $f[] = " Options None"; $f[] = " Order allow,deny"; $f[] = " Allow from all"; $f[] = "</Directory>"; $f[] = ""; $f[] = ""; $f[] = "DefaultType text/plain"; $f[] = ""; $f[] = "<IfModule mime_module>"; $f[] = " "; $f[] = " TypesConfig /etc/mime.types"; $f[] = " #AddType application/x-gzip .tgz"; $f[] = " AddType application/x-compress .Z"; $f[] = " AddType application/x-gzip .gz .tgz"; $f[] = " AddType application/x-httpd-php .php .phtml"; $f[] = " #AddHandler cgi-script .cgi"; $f[] = " #AddHandler type-map var"; $f[] = " #AddType text/html .shtml"; $f[] = " #AddOutputFilter INCLUDES .shtml"; $f[] = "</IfModule>"; @file_put_contents('/etc/zarafa/httpd.conf', @implode("\n", $f) . "\n"); if ($GLOBALS["OUTPUT"]) { echo "Configuring...: " . date("H:i:s") . " /etc/zarafa/httpd.conf done\n"; } }