TYPO3 is an enterprise content management system, so it is thread safe—meaning two instances of the script can be executed simultaneously, and they will run in parallel without interfering with each other. Therefore, Apache can be set up with
mod_fcgid and PHP processes will be allowed to run in parallel.
1. Install components of the server:
Shell> apt-get install libapache2-mod-fcgid apache2-mpm-worker php5-cgi Shell> a2enmod actions Shell> a2enmod fcgid
2. Replace contents of
<IfModule mod_fcgid.c> AddHandler fcgid-script .fcgi SocketPath /var/lib/apache2/fcgid/sock IPCConnectTimeout 60 IPCCommTimeout 256 BusyTimeout 256 ProcessLifeTime 256 </IfModule>
3. Modify site configuration, by default located in
4. Add the following to the virtual host definition:
Alias /fcgi-bin/ /var/www/fcgi-bin.d/ Action php-fcgi /fcgi-bin/php-fcgi-wrapper
5. Add the following lines to the directory definition for
AddHandler fcgid-script .php FCGIWrapper /usr/bin/php-cgi .php
<VirtualHost *:80> ServerAdmin webmaster@localhost Alias /fcgi-bin/ /var/www/fcgi-bin.d/ Action php-fcgi /fcgi-bin/php-fcgi-wrapper DocumentRoot /var/www/ <Directory /var/www/> AddHandler fcgid-script .php FCGIWrapper /usr/bin/php-cgi .php Options Indexes FollowSymLinks MultiViews +ExecCGI AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost>
Refer to the Apache manual for descriptions of some of the options listed above, as well as other configuration options.
7. Create the executable link to PHP CGI module:
Shell> mkdir /var/www/fcgi-bin.d Shell> ln s /usr/bin/php5-cgi /var/www/fcgi-bin.d/php-fcgi-wrapper
We then enable the
fcgid Apache module, and adjust its configuration. Most installations need to increase the timeout; otherwise, you will be looking at an Internal Server Error if the page rendering takes too long. To further complicate the diagnosis, timeouts are not recorded in logs. We increase the values of
IPCConnectTimeout, IPCCommTimeout, and
BusyTimeout, along with the
ProcessLifeTime. Depending on your configuration, you may need to increase these values further.
Now, when a request comes in to Apache, the PHP CGI process will be launched to handle it. With multiple simultaneous requests, multiple processes will be launched, and run parallel to each other, handling individual requests.
If you have multiple clients using this server, they can have separate PHP processes, and not interfere with each other (for security purposes). You can find more information on configuring this set up at http://typo3.org/development/articles/using-php-with-mod-fcgid/.