Configuration and apache modules

How to configure Apache for GABOX ?

To operate the framework GABOX, it is necessary to define an apache configuration for each environment (front and back office)


It will of course be possible to operate only one of the two environments according to the needs.
Note that what follows does not take into account all the possible optimizations, or guarding the server side, and only shows the minimum configuration for the framework works

Back office

<virtualhost :80=""><br /> ServerName admin.mon-site.com<br /> # env is your environment, typically : dev, preprod or prod<br /> setEnv env dev<br /> # usr corresponds to your directory of the project that can be found in the DocumentRoot<br /> setEnv usr-my site<br /> # back allows to specify that one is in the back office so here 1<br /> SetEnv back 1<br /> # front allows you to define whether it is front office so here 0<br /> SetEnv front 0<br /> # prod allows you to define if one is in production mode or not (used primarily for recovery of application errors)<br /> SetEnv prod 0<br /><br /> DocumentRoot /var/www/path/to/my/site/usr/my-site/admin/<br /><br /> php_admin_value upload_tmp_dir "/var/www/path/to/my/site/usr/my-site/var/upload"<br /> php_admin_value auto_prepend_file "/var/www/chemin/vers/mon/site/include/autoprepend.php"<br /> AddDefaultCharset utf-8<br /> php_value default_charset utf-8<br /><br /><directory var="" www="" chemin="" vers="" mon="" site="" usr="" mon-site="" admin=""></directory><br /> Options -Indexes<br /><br /></virtualhost>

Front office

The URLs of front office must be the parameter id_site
Two possibilities :
- Use an alias to URL and specify the id_site in the first element of the url, for example 1.front.mon-site.com (useful platforms for multi-site pre-production)
- Set directly in the apache configuration this id_site via SetEnv (rather used in production with URLs final)

In the configuration example above, we will use the first opportunity


ServerAlias *.front.mon-site.com *.alias.mon-site.com mon-adresse-finale.com
SetEnvIf Host ^([^.]*).* id_site=$1

# This line allows to define the current language in the case of a site multilingual
SetEnvIf Request_URI ^/(..)/(.*)?$ lang=$1

SetEnv front 1
SetEnv usr-my site
setEnv env dev
SetEnv prod 0

DirectoryIndex index.php
DocumentRoot /var/www/path/to/my/site/usr/my-site/www/
php_admin_value upload_tmp_dir "/var/www/path/to/my/site/usr/my-site/var/upload"

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !\.(?:png|shtml|gif|jpeg|jpg|webp|pdf|js|ico|txt|css|rar|zip|png|tar\.gz|woff|woff2|map|json|eto|ttf|svg|mp4|eot|docx|xml|PNG|GIF|JPEG|JPG|WEBP|PDF|JS|ICO|TXT|CSS|RAR|ZIP|PNG|TAR\.GZ|WOFF|WOFF2|MAP|JSON|ETO|TTF|SVG|MP4|EOT|DOCX|XML)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [QSA]

php_admin_value auto_prepend_file "/var/www/chemin/vers/mon/site/include/autoprepend.php"
php_admin_value auto_append_file "/var/www/chemin/vers/mon/site/include/autoappend.php"
AddDefaultCharset utf-8
php_value default_charset utf-8

<Directory "/var/www/chemin/vers/mon/site/usr/mon-site/www/">
Options MultiViews FollowSymLinks Includes
AllowOverride FileInfo
Order allow,deny
Allow from all


Apache Modules needed

The following modules are the minimum required to run a platform-as-GABOX :
- alias
- approx
- php5
- rewrite
- setenvif