Tag Archive | "FastCgi"

Tags: ,

Configure Apache Via PHP FastCGI


FastCGI’s main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once. Also, PHP is not recommended with multithreaded Apache2 (worker MPM) because of performance and some 3rd party PHP extensions are not not guaranteed thread-safe.

This tutorial is about Apache 2 + mod_fastcgi + PHP installation and configuration under Red Hat Enterprise Linux / CentOS Linux version 5.x+.

1. Install mod_fastcgi

Make sure required packages are installed (httpd-devel and apr-devel required to compile mod_fastcgi), enter:
# yum install libtool httpd-devel apr-devel apr
Next, grab the latest mod_fastcgi source code, enter:
# cd opt
# wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz

a. Untar tar ball, type:
# tar -zxvf mod_fastcgi-current.tar.gz
# cd mod_fastcgi-2.4.6

Make a copy of Makefile.AP2, enter:
# cp Makefile.AP2 Makefile
Compile and install mod_fastcgi for 32 bit system, enter:
# make top_dir=/usr/lib/httpd
# make install top_dir=/usr/lib/httpd

b. Compile and install mod_fastcgi for 64 bit system, enter:
# make top_dir=/usr/lib64/httpd
# make install top_dir=/usr/lib64/httpd

c. Configure mod_fastcgi

Open /etc/httpd/conf.d/mod_fastcgi.conf file
# vi /etc/httpd/conf.d/mod_fastcgi.conf
Add an entry to it like this:
LoadModule fastcgi_module modules/mod_fastcgi.so
Save and close the file. Restart httpd, enter:
# service httpd restart

2. Configure PHP as FastCGI process under RHEL / CentOS Linux

a. disable mod_php5
# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable

Create a script as follows in /var/www/cgi-bin/php.fcgi (or put in your virtual domain cgi-bin directory)
#!/bin/bash
# Shell Script To Run PHP5 using mod_fastcgi under Apache 2.x
# Tested under Red Hat Enterprise Linux / CentOS 5.x
### Set PATH ###
PHP_CGI=/usr/bin/php-cgi
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
### no editing below ###
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI

b. Set permission, type:
# chmod +x /var/www/cgi-bin/php.fcgi

3. Finally, modify documentroot directory permission as follows. You need to use AddHandler and Action directives for mod_fastcgi:

 <Directory "/var/www/html">
   Options -Indexes FollowSymLinks +ExecCGI
    AllowOverride AuthConfig FileInfo
    AddHandler php5-fastcgi .php
    Action php5-fastcgi /cgi-bin/php.fcgi
    DirectoryIndex index.php index.html
    Order allow,deny
    Allow from all
</Directory>

Save and close the file. Restart httpd:
# service httpd restart

Source article from cyberciti.biz

Share

Posted in Linux-Apache-PHPComments (0)

Tags: ,

How to Install PHP under windows server 2008


If you’re using windows server 2008, In order to take the advantage of all the new features of PHP release, it needs to be running as FastCgi mode under IIS7. Here’s the official site for this deployment:

http://learn.iis.net/page.aspx/770/install-the-microsoft-web-platform-for-php/

Share

Posted in Windows-IIS-ASPNETComments (0)