diff --git a/bin/vhost.sh b/bin/vhost.sh index 36bb7ee6e0..2b15fbea60 100755 --- a/bin/vhost.sh +++ b/bin/vhost.sh @@ -95,8 +95,8 @@ Arguments: [--sf-trusted-proxies=127.0.0.1,....] : Comma separated trusted proxies (e.g. Varnish), that we can get client ip from [--sf-http-cache=0|1] : To disable Symfony HTTP cache Proxy for using a different reverse proxy By default disabled when evn is "dev", enabled otherwise. - [--sf-http-cache-class=] : To specify a different class then default to use as the Symfony proxy - [--sf-classloader-file=] : To specify a different class then default to use for PHP auto loading + [--sf-http-cache-class=] : DEPRECATED - To specify a different class then default to use as the Symfony proxy + [--sf-classloader-file=] : DEPRECATED - To specify a different class then default to use for PHP auto loading [--body-size-limit=] : Limit in megabytes for max size of request body, 0 value disables limit. [--request-timeout=] : Limit in seconds before timeout of request, 0 value disables timeout limit. [--binary-data-handler=dfs|] : Name of handler in user. Specify "dfs" if you are using the dfs io handler. @@ -272,6 +272,9 @@ while [ "${template_vars[$COUNTER]}" != "" ]; do fi done else + # Change "#if[!VAR] " comments conditionally to uncommented lines + tmp=${tmp//"#if[!${current_var}] "/""} + # Change #if[VARIABLE[...]] comments to conventional comment lines regex="if\[${current_var}([^]]*)\] " while [[ $tmp =~ $regex ]] ; do diff --git a/doc/apache2/Readme.md b/doc/apache2/Readme.md index ad1fc13043..4acab60037 100644 --- a/doc/apache2/Readme.md +++ b/doc/apache2/Readme.md @@ -67,13 +67,13 @@ Example config for Apache 2.4 in prefork mode: # Access to repository images in single server setup RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L] - # Makes it possible to place your favicon at the root `web` directory in your eZ instance. - # It will then be served directly. + # Makes it possible to placed your favicon and robots.txt at the root of your web folder RewriteRule ^/favicon\.ico - [L] RewriteRule ^/robots\.txt - [L] - # The following rule is needed to correctly display assets from eZ / Symfony bundles + # The following rules are needed to correctly display bundle and project assets RewriteRule ^/bundles/ - [L] + RewriteRule ^/assets/ - [L] # Additional Assetic rules for environments different from dev, # remember to run php app/console assetic:dump --env=prod @@ -133,11 +133,14 @@ If you do not have an access to use virtualhost config, use the `.htaccess` file Virtual host template --------------------- -This folder contains `vhost.template` file which provides more features you can enable in your virtual host configuration. You may also use this file as a `.htaccess` config. However, you will need to adjust rewrite rules to remove `/` like in the example above. +This folder contains `vhost.template` for Apache 2.4, and `vhost.2.2.template` for Apache 2.2, both which provides more +features you can enable in your virtual host configuration. You may also use this file as a `.htaccess` config. However, +you will need to adjust rewrite rules to remove `/` like in the example above. *Note: vhost.template uses `mod_setenvif`, adapt it as indicated inline if you can't install it.* -Bash script *(Unix/Linux/OS X)* exists to be able to generate the configuration. To display help text, execute the following from the eZ installation root: +Bash script *(Unix/Linux/OS X)* exists to be able to generate the configuration. To display help text, execute the +following from the eZ installation root: ```bash ./bin/vhost.sh -h ``` diff --git a/doc/apache2/vhost.2.2.template b/doc/apache2/vhost.2.2.template new file mode 100644 index 0000000000..cbb93f778d --- /dev/null +++ b/doc/apache2/vhost.2.2.template @@ -0,0 +1,110 @@ +# Official VirtualHost configuration for Apache 2.2. template +## Deprecated, please plan your move to Apache 2.4 or Nginx +# See Readme.md for how to generate your config manually, or in automated deployments. +# Note: This is meant to be manually tailored for your needs, expires headers might for instance not work for your dev setup. + +# NameVirtualHost %IP_ADDRESS% + + + ServerName %HOST_NAME% + ServerAlias %HOST_ALIAS% + DocumentRoot %BASEDIR%/web + DirectoryIndex app.php + + # Request size limit in bytes, 0 to disable + LimitRequestBody %BODY_SIZE_LIMIT% + + # Request timeout limit in seconds, 0 to disable + TimeOut %TIMEOUT% + + # Enabled for Dev environment + #LogLevel debug + + # "web" folder is what we expose to the world, all rewrite rules further down is relative to it. + + # If using php configured in FastCGI mode, you might also need to add "ExecCGI" to the line below + Options FollowSymLinks + AllowOverride None + # Depending on your global Apache settings, you may need to uncomment and adapt: + #Allow from all + + + ## eZ Platform/Symfony ENVIRONMENT variables, for customizing app.php* execution + # * Only SYMFONY_ENV and SYMFONY_DEBUG supported by console command, rest are eZ Platform features in app.php. + + # Environment. + # Possible values: "prod" and "dev" out-of-the-box, other values possible with proper configuration + # Defaults to "prod" if omitted (uses SetEnvIf so value can be used in rewrite rules) + #if[SYMFONY_ENV] SetEnvIf Request_URI ".*" SYMFONY_ENV=%SYMFONY_ENV% + + # Optional: Whether to use debugging. + # Possible values: 0, 1 or "" + # Defaults to enabled if SYMFONY_ENV is set to "dev" if env value is omitted or empty + #if[SYMFONY_DEBUG] SetEnv SYMFONY_DEBUG "%SYMFONY_DEBUG%" + + # Optional: Whether to use custom ClassLoader (autoloader) file + # Needs to be a valid path relative to root web/ directory + # Defaults to bootstrap.php.cache, or autoload.php in debug if env value is omitted or empty + #if[SYMFONY_CLASSLOADER_FILE] SetEnv SYMFONY_CLASSLOADER_FILE "%SYMFONY_CLASSLOADER_FILE%" + + # Optional: Whether to use Symfony's builtin HTTP Caching Proxy. + # Disable it if you are using an external reverse proxy (e.g. Varnish) + # Possible values: 0, 1 or "" + # Defaults to disabled if SYMFONY_ENV is set to "dev" or SYMFONY_TRUSTED_PROXIES is set, + # and if this env value is omitted or empty + #if[SYMFONY_HTTP_CACHE] SetEnv SYMFONY_HTTP_CACHE "%SYMFONY_HTTP_CACHE%" + + # Optional: Whether to use custom HTTP Cache class if SYMFONY_HTTP_CACHE is enabled + # Value must be a autoloadable cache class + # Defaults to to use provided "AppCache" if env value is omitted or empty + #if[SYMFONY_HTTP_CACHE_CLASS] SetEnv SYMFONY_HTTP_CACHE_CLASS "%SYMFONY_HTTP_CACHE_CLASS%" + + # Optional: Defines the proxies to trust + # Needed when using Varnish as proxy, if so disable SYMFONY_HTTP_CACHE. + # Separate entries by a comma, example: "proxy1.example.com,proxy2.example.org" + # Defaults to not be set if env value is omitted or empty + #if[SYMFONY_TRUSTED_PROXIES] SetEnv SYMFONY_TRUSTED_PROXIES "%SYMFONY_TRUSTED_PROXIES%" + + + RewriteEngine On + + # For FastCGI mode or when using PHP-FPM, to get basic auth working. + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Cluster/streamed files rewrite rules. Enable on cluster with DFS as a binary data handler + RewriteCond %{ENV:BINARY_DATA_HANDLER} "dfs" + RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* /app.php [L] + + RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L] + + # Makes it possible to placed your favicon and robots.txt at the root of your web folder + RewriteRule ^/favicon\.ico - [L] + RewriteRule ^/robots\.txt - [L] + + # The following rules are needed to correctly display bundle and project assets + RewriteRule ^/bundles/ - [L] + RewriteRule ^/assets/ - [L] + + # Additional Assetic rules for environments different from dev, + # remember to run php app/console assetic:dump --env=prod + RewriteCond %{ENV:SYMFONY_ENV} !^(dev) + RewriteRule ^/(css|js|fonts?)/.*\.(css|js|otf|eot|ttf|svg|woff) - [L] + + # Prevent access to website with direct usage of app.php in URL + RewriteRule ^/(.+/)?app\.php - [R=404,L] + + RewriteRule .* /app.php + + + # Everything below is optional to improve performance by forcing + # clients to cache image and design files, change the expires time + # to suite project needs. + + + # eZ Platform appends the version number to image URL (ezimage + # datatype) so when an image is updated, its URL changes too + ExpiresActive on + ExpiresDefault "now plus 10 years" + + + diff --git a/doc/apache2/vhost.template b/doc/apache2/vhost.template index 271593c528..32f4078cf6 100644 --- a/doc/apache2/vhost.template +++ b/doc/apache2/vhost.template @@ -1,4 +1,4 @@ -# Official VirtualHost configuration for Apache 2.x template +# Official VirtualHost configuration for Apache 2.4 template # See Readme.md for how to generate your config manually, or in automated deployments. # Note: This is meant to be manually tailored for your needs, expires headers might for instance not work for your dev setup. @@ -17,37 +17,47 @@ TimeOut %TIMEOUT% # Enabled for Dev environment - # LogLevel debug + #LogLevel debug # "web" folder is what we expose to the world, all rewrite rules further down is relative to it. - # If using php configured in FastCGI mode, you might also need to add "ExecCGI" to the line below + + # For serving php files configure mod_proxy to talk to php-fpm using Apache 2.4.10 and higher. + # See: https://wiki.apache.org/httpd/PHP-FPM#apache_httpd_2.4 + + # For best performance, prefer socket use. This requires Linux, and that both Apache and PHP has access to + # the socket file `/var/run/php5-fpm.sock` via local file system and hence run on the same machine. + #SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/" + # For TCP usage, if you're not on Linux, or Apache and PHP are on separate machines, instead use fcgi: form. + # (Optionally hint php-fpm processes count using: https://wiki.apache.org/httpd/PHP-FPM#Proxy_via_handler) + #SetHandler "proxy:fcgi://localhost/:9000" + + SetHandler "proxy:%FASTCGI_PASS%|fcgi://localhost/" + + Options FollowSymLinks AllowOverride None - # Depending on your global Apache settings, you may need to uncomment and adapt: - # for Apache 2.2 and earlier: - #Allow from all - # for Apache 2.4: - #Require all granted + Require all granted - ## eZ Platform/Symfony ENVIRONMENT variables, used for customizing app.php execution (not used by console commands) + ## eZ Platform/Symfony ENVIRONMENT variables, for customizing app.php* execution + # * Only SYMFONY_ENV and SYMFONY_DEBUG supported by console command, rest are eZ Platform features in app.php. # Environment. # Possible values: "prod" and "dev" out-of-the-box, other values possible with proper configuration # Defaults to "prod" if omitted (uses SetEnvIf so value can be used in rewrite rules) #if[SYMFONY_ENV] SetEnvIf Request_URI ".*" SYMFONY_ENV=%SYMFONY_ENV% - # Optional: Whether to use custom ClassLoader (autoloader) file - # Needs to be a valid path relative to root web/ directory - # Defaults to bootstrap.php.cache, or autoload.php in debug if env value is omitted or empty - #if[SYMFONY_CLASSLOADER_FILE] SetEnv SYMFONY_CLASSLOADER_FILE "%SYMFONY_CLASSLOADER_FILE%" - # Optional: Whether to use debugging. # Possible values: 0, 1 or "" # Defaults to enabled if SYMFONY_ENV is set to "dev" if env value is omitted or empty #if[SYMFONY_DEBUG] SetEnv SYMFONY_DEBUG "%SYMFONY_DEBUG%" + # Optional: Whether to use custom ClassLoader (autoloader) file + # Needs to be a valid path relative to root web/ directory + # Defaults to bootstrap.php.cache, or autoload.php in debug if env value is omitted or empty + #if[SYMFONY_CLASSLOADER_FILE] SetEnv SYMFONY_CLASSLOADER_FILE "%SYMFONY_CLASSLOADER_FILE%" + # Optional: Whether to use Symfony's builtin HTTP Caching Proxy. # Disable it if you are using an external reverse proxy (e.g. Varnish) # Possible values: 0, 1 or "" @@ -78,18 +88,11 @@ RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L] - # Makes it possible to place your favicon at the root of your eZ Platform instance. - # It will then be served directly. + # Makes it possible to placed your favicon and robots.txt at the root of your web folder RewriteRule ^/favicon\.ico - [L] - - # Give direct access to robots.txt for use by crawlers (Google, Bing, Spammers...) RewriteRule ^/robots\.txt - [L] - # Platform for Privacy Preferences Project ( P3P ) related files for Internet Explorer - # More info here : http://en.wikipedia.org/wiki/P3p - RewriteRule ^/w3c/p3p\.xml - [L] - - # The following rule is needed to correctly display bundle and project assets + # The following rules are needed to correctly display bundle and project assets RewriteRule ^/bundles/ - [L] RewriteRule ^/assets/ - [L]