TYPO3 Flow Base DistributionPackagesApplications

Feature #5690

Getting started documentation - setting the environment variables for FCGI

Added by Marco Weber over 5 years ago. Updated almost 5 years ago.

Status:Accepted Start date:2009-12-09
Priority:Should have Due date:
Assigned To:Robert Lemke % Done:

0%

Category:Content / Instructions
Target version:1.0.0 alpha 7

Description

It is very important, that people are informed in the Getting Started Doumentation, that somethimes the "SetEnv FLOW3_CONTEXT Development" Directive doesn't set the environment variables in PHP!

In case you're using an SUEXEC/FCGI PHP Version in Apache, SUEXEC wont pass FLOW3_CONTEXT to the fcgi script...
( Because the varible wasn't defined in "Safe-Vars" on SUEXEC compilation time. )
Since providers propably won't recompile SUEXEC with FLOW3_CONTEXT defined in "Safe-Vars", php won't receive the value SET with SetEnv in apache...

In this case i've found just 3 quick solutions to set the environment variable:

Solution 1: In the FCGI Starter Script:
It usually looks something like this:

#!/bin/sh
FLOW3_CONTEXT='Development'
export FLOW3_CONTEXT
PHPRC="/path/to/php5/conf/directory" 
export PHPRC
PHP_FCGI_CHILDREN=5
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec '/path/to/php5.3/bin/php-cgi'

Solution 2: Creating a prepend file in your php.ini
Create a prepend file that looks like this:

<?php
$_SERVER['FLOW3_CONTEXT']='Development';
?>

Finally, set the "auto_prepend_file = /path/to/your/prepend-file.php" option in your php.ini

Solution 3: Alter the Web/index.php file
Add the following line to the file after the "define" line:

$_SERVER['FLOW3_CONTEXT']='Development';

There might be other ways to set the environment variable, but this should be mentioned in the documentation.

History

#1 Updated by Karsten Dambekalns over 5 years ago

  • Project changed from TYPO3.Flow to Getting Started

#2 Updated by Karsten Dambekalns over 5 years ago

  • Category set to Content / Instructions
  • Status changed from New to Accepted
  • Assigned To set to Karsten Dambekalns
  • Priority changed from Must have to Should have

#3 Updated by Karsten Dambekalns over 5 years ago

  • Target version set to 1.0.0 alpha 7

#4 Updated by Alois Baule over 5 years ago

I'm using Flow3 1.0.0 alpha6 and tried your solutions #2 und #3. But they did not show any effect.

I succeeded in altering Web/index.php by adding the following line after declare(...):

putenv('FLOW3_CONTEXT=Development');

#5 Updated by Karsten Dambekalns over 5 years ago

  • Assigned To changed from Karsten Dambekalns to Robert Lemke

#6 Updated by Marco Weber over 5 years ago

Alois Baule wrote:

I'm using Flow3 1.0.0 alpha6 and tried your solutions #2 und #3. But they did not show any effect.

I succeeded in altering Web/index.php by adding the following line after declare(...):

putenv('FLOW3_CONTEXT=Development');

Hi Alois,

Thanks for the tipp, that $_SERVER['FLOW3_CONTEXT']='Development'; should be replaced by putenv('FLOW3_CONTEXT=Development');

To Solution 1: What kind of fcgi configuration do you use? And on which OS?
( Solution 1 only works, when you have a wrapper script in your fcgi-bin and don't call the php binary directly. )

See You Marco Weber

#7 Updated by Marco Weber over 5 years ago

It might be better to replace the line:
$_SERVER['FLOW3_CONTEXT']='Development';

with the following line:
putenv('FLOW3_CONTEXT=Development');

Also available in: Atom PDF