|
Sunday, 25 February 2007 22:21 |

| Since I am facing performance problem due to the load of visitors and a badly configured server, I decide today to document my findings in this new series of articles.
FastCGI is an extention to CGI that increases speed. Instead of creating a new process every time a page is reloaded, FastCGI will use the same process, queuing up requests. This increases startup speed, at the expense of forcing users to wait for the previous requests to finish. FastCGI also allows programs to get the web server to do certain operations, like reading in a file, before the request is handed over. [WikiPedia]
FastCGI provides a way to keep PHP frequently-run script files loaded on Your server so that script are already preloaded and initialized the next time they are used. This can make some scripts run up to five times more quickly (in most cases it's as fast as mod_php, without the drawbacks). Moreover You can run different version of PHP (PHP4 and PHP5) in the same server...
Server: Strato (www.strato.de)
Operating system: SuSE / openSuSE
Requirements: root access and basic Unix knowledge
|
| 1 |
Use
yast2 to install mod_fastcgi
on the system, this will create files
(*.so) in /usr/lib/apache2-worker/
and /usr/lib/apache2-prefork/ |
| 2 |
Edit
the file
#
vi /etc/sysconfig/apache2
and add fastcgi,
suexec
remove php4/php5 if any
APACHE_MODULES="fastcgi cache
mem_cache deflate
headers access
actions alias auth auth_dbm autoindex cgi dir env expires
include log_config mime negotiation setenvif ssl
userdir php4
php5
perl rewrite suexec" |
| 3 |
create
a new file in /etc/apache2/conf.d/mod_fastcgi.conf
#vi
/etc/apache2/conf.d/mod_fastcgi.conf
and add these lines, at the end of
file, adapt all path according to your system. Keep in mind, I have a
SuSE system
<IfModule
mod_fastcgi.c>
ScriptAlias /fcgi-bin/ /srv/www/fcgi-bin/
FastCgiIpcDir /var/lib/apache2/fastcgi
# FastCGI
applications can be static, dynamic, or external.
# Dynamic FastCGI applications can be put in this directory.
# Use the FastCgiConfig directive in your httpd.conf.local
# to change the defaults for them.
# http://www.fastcgi.com/mod_fastcgi/docs/
# mod_fastcgi.html#FastCgiConfig
<Directory "/srv/www/fcgi-bin">
AllowOverride None
Options +ExecCGI -Includes
SetHandler fastcgi-script
Order allow,deny
Allow from all
</Directory>
AddHandler fastcgi-script fcg fcgi fpl
# Static or
external FastCGI applications are started when apache
# is started. They are configured with the
# FastCgiServer and FastCgiExternalServer directives:
# http://www.fastcgi.com/mod_fastcgi/docs/
# mod_fastcgi.html#FastCgiServer
# http://www.fastcgi.com/mod_fastcgi/docs/
# mod_fastcgi.html#FastCgiExternalServer
# which can be put into httpd.conf.local.
#
# Examples:
#FastCgiServer /srv/www/fcgi-bin/echo -processes 5
#FastCgiServer /srv/www/htdocs/some/path/echo.fcgi
# see http://www.FastCGI.com/docs/faq.html#typical_httpd.conf
# for more information...
Alias /php5-fcgi/ /srv/www/cgi-bin/
FastCgiServer /srv/www/cgi-bin/php5 -processes 5
AddType application/x-httpd-fastphp5 .php5
Action application/x-httpd-fastphp5 /php5-fcgi/php5
Alias /php4-fcgi/ /srv/www/cgi-bin/
FastCgiServer /srv/www/cgi-bin/php -processes 5
AddType application/x-httpd-fastphp4 .php
Action application/x-httpd-fastphp4 /php5-fcgi/php
</IfModule>
|
| 4 |
start
#
apache2-reconfigure-mpm
this recreate the file
/etc/apache2/sysconfig.d/loadmodule.conf
and restart apache automatically. |
References:
|
|
Last Updated ( Sunday, 25 February 2007 22:34 )
|