ServerConfig
From fCMS
The fCMS SiteSystem requires only a very limited amount of fine tuing to get everything up and running. This page will try to explain the settings available and how you may have to modify them to get the most out of the system.
Contents |
[edit] Apache Config
To get userfriendly urls, to make indexing easier for search engines and to allow a higher flexibility on url creation, mod_rewrite is used to map pseudo static urls. For security and other reasons, some of php configuration settings are also assumed and should be enforced either by .htaccess or by defining them within the vhost container of apache. Otherwise the fCMS Core System might refuse to work in your environment:
[edit] PHP as Module
<VirtualHost ....>
# php settings php_flag register_globals 0 php_flag magic_quotes_gpc 0 php_flag magic_quotes_runtime 0 php_flag short_open_tag 0 php_flag track_errors 1 php_value arg_separator.output "&"
# fCMS v5 rewrite RewriteEngine On
# filter language RewriteRule "/(.+)/site/(.+)" "/site/$2&fCMSlang=$1" RewriteRule "/(.+)/binary/(.+)" "/binary/$2&fCMSlang=$1" RewriteRule "/(.+)/soap/(.+)" "/soap/$2&fCMSlang=$1"
# rewrite to site / binary system RewriteRule "/(site|binary)/(.+)" "/f$1.php?fCMSpage=$2&%{QUERY_STRING}"
# rewrite for soap system (skip if not used) RewriteRule "/soap/(.+)" "/fsoap.php?class=$1&%{QUERY_STRING}"
# rewrite for fscript javascript framework loads Alias "/fscript/" "/path/to/fcms_system/v5.0/modules/fscript/classes/"
</VirtualHost>
[edit] PHP as CGI
<VirtualHost ....>
# php settings php_flag register_globals 0 php_flag magic_quotes_gpc 0 php_flag magic_quotes_runtime 0 php_flag short_open_tag 0 php_flag track_errors 1
php_value arg_separator.output "&"
# fCMS v5 rewrite RewriteEngine On
# filter language RewriteCond %{REQUEST_URI} !^/?cgi-bin/.+ RewriteRule "/(.+)/site/(.+)" "/site/$2&fCMSlang=$1"
RewriteCond %{REQUEST_URI} !^/?cgi-bin/.+ RewriteRule "/(.+)/binary/(.+)" "/binary/$2&fCMSlang=$1"
RewriteCond %{REQUEST_URI} !^/?cgi-bin/.+ RewriteRule "/(.+)/soap/(.+)" "/soap/$2&fCMSlang=$1"
# rewrite to site / binary system RewriteRule "^/(site|binary)/(.+)" "/f$1.php?fCMSpage=$2&%{QUERY_STRING}"
# rewrite for soap system (skip if not used) RewriteRule "^/soap/(.+)" "/fsoap.php?class=$1&%{QUERY_STRING}"
# Alias for fscript javascript framework loads Alias "/fscript/" "/path/to/fcms_system/v5.0/modules/fscript/classes/"
</VirtualHost>
[edit] Lighttpd (aka lighty) Config
For users of the lighttpd webserver the following rewrite rule and alias can be used.
url.rewrite-once = (
"^/(?:([a-z]{2}|[a-z]{2}[-|_]{1}[a-zA-Z]{2})/)?(site|binary)/([^\?]+)(\?(.*))?" => "/f$2.php?fCMSpage=$3&fCMSlang=$1&$5"
)
alias.url = (
"/fscript" => "/home/nonfood/fcms_system/v5.0/modules/fscript/classes/"
)
Please make sure that the rewrite and alias modules within lighttpd.conf are enabled or those lines will not work.
[edit] fCMS Config
Configuring the fCMS SiteSystem for a "client" website contains of modifying / creating two simple files:
[edit] index.php
This is a simple redirection page, detecting the user's browser-language in case no other language has been specified. If you only provide one language, the code can be shortened to just blindly redirect.
The only interesting part of the index.php is the array, listing supported languages:
$avail[]='en';
The index.php tries to find the best match in the list of available languages based on the browser language specified,
and uses the first language defined as fallback in case no match was found.
[edit] Example index.php
<?php
/** * fCMS v5 live index
* --------------------------------------------
* * @package fCMSv5.0 * Page-level DocBlock * * @copyright Copyright (C) 2005 SalesEomtion Adsolutions GmbH * @version $Version$ * @id $Id: index.php,v 1.1 2005/05/24 08:55:21 kai Exp $ * */
// Config $avail[]="en";
// url predefined if ($_GET["fCMSlang"] && in_array($_GET["fCMSlang"],$avail)) { $lang[]=basename($_GET["fCMSlang"]); }
// Browser predefined if ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) { $tmp=split(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]); foreach ($tmp as $sel) { $t1=split(';',$sel); $t2=split('-',$t1[0]); if (in_array($t2[0],$avail)) { $lang[]=$t2[0]; } } }
// For no match set Fallback if (count($lang)==0) { $lang[]=$avail[0]; }
// Redirect to start page Header("Location: http://{$_SERVER["HTTP_HOST"]}/{$lang[0]}/site/index.xml");
?>
[edit] fsite.php / fbinary.php / fsoap.php
These are the core SiteSystem files, providing the main runtime configuration and the real system calls for a website. All Settings are stored in constants to avoid overriding and to make them automatically available in all scopes. The following options can be defined here by default, however, modules may require additional settings:
[edit] RUNTIME
- description: Define the path to the fCMS v5.0 sitesystem runtime code
- default: /webspace/fcms_system/v5.0 (This value is very likely to be wrong for your environment!)
- required: yes
[edit] DOCROOT
- description: Define Document root
- default: dirname(__FILE__)
- required: no
[edit] FCMSBASE
- description: Path to sitedepenend fCMS subcomponents
- default: realpath(DOCROOT.'/../fcms')
- required: yes
[edit] TIDY
- description: if ext/tidy has been compiled in, enable or disable use of it
- default: OFF (set to ON to use tidy to cleanup xhtml result)
- required: no
[edit] DEBUG
- description: enable or disable use of fDebug support
- default: ON (set to OFF on production systems for higher speed, see fDEBUG_* for security settings)
- required: no
[edit] CACHE
- description: globally enable or disable use of the cache subsystem
- default: ON (set to OFF for development servers)
- required: no
[edit] CACHEMODE
- description: if the fCACHE Daemon is in use, set to EXTERNAL, otherwise use TIME
- default: TIME (System will do a timestamp check on files)
- required: no
[edit] ERRORLOG
- description: capture errors in this logfile
- default: n/a
- required: no
[edit] ERRORPAGE
- description: in case of a fatal error, redirect user to this page
- default: n/a
- required: no
[edit] fDEBUG_HOST
- description: list of IPs allowed to send fDEBUG information to, seperated by space
- default: 127.0.0.1
- required: no
[edit] fDEBUG_PORT
- description: port to connect to send fDEBUG to
- default: 5005
- required: no
[edit] DATABASE
- description: global database dsn (format: mysql://user:pwd@hostname/dbname)
- default: n/a
- required: no
[edit] ACLFILE
- description: filename of the XML config file for access control (see AclProcessor)
- default: control.xml
- required: no
[edit] Example fsite.php
<?php
/** * fCMS v5 live core * -------------------------------------------- * * @package fCMSv5.0 * Page-level DocBlock * * @copyright Copyright (C) 2005 SalesEomtion AdSolutions GmbH * @version $Version$ * */
// Path Setup define('RUNTIME', '/webspace/fcms_system/v5.0'); define('DOCROOT', dirname(__FILE__)); define('FCMSBASE', realpath(DOCROOT.'/../fcms'));
// config switches define('TIDY', 'OFF'); define('DEBUG', 'ON'); define('CACHE', 'OFF');
// error handling and logging //define('ERRORLOG', '/tmp/fcmsv5_error_log'); //define('ERRORPAGE', '/de/site/pageXX.xml');
// define cache mode // TIME = CACHE > 1H or FILEMTIME mismatch // BLIND = Blindly use cache without checking define('CACHEMODE', 'TIME');
define('fDEBUG_HOSTS', '127.0.0.1 192.168.1.92 192.168.1.96'); define('fDEBUG_PORT', '5005');
define('DATABASE', 'mysql://dev:dev@db.local.dev/dev'); define('ACLFILE', 'control.xml');
// load core require_once(RUNTIME.'/fcore.lib.fcmsv5.php');
// start subsystem $sys=new fCore; $sys->exec('fSite');
?>
