Apache fastcgi

From ArchWiki

Jump to: navigation, search


i18n
English
Español

This goal of this how to is to setup Apache to use external fastcgi.
--cactus 19:35, 9 Sep 2005 (EDT)

Contents

[edit] Requirements

You need to fulfill the requirements before you can get fastcgi Apache running. Those requirements are:

  • apache
  • fcgi
  • mod_fastcgi

[edit] Install

[edit] Fulfill the Requirements

Fetch pacman packages.

$ pacman -Sy fcgi apache

[edit] Fetch mod_fastcgi

$  wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz

[edit] Extract mod_fastcgi

$ tar -xzf mod_fastcgi-2.4.2.tar.gz
$ cd mod_fastcgi-2.4.2

[edit] Modification of files

$ cp Makefile.AP2 Makefile

You now need to edit the Makefile:

builddir     = .

top_dir      = /home/httpd

top_srcdir   = ${top_dir}
top_builddir = ${top_dir}

include ${top_builddir}/build/special.mk

APXS      = apxs
APACHECTL = apachectl

#DEFS=-Dmy_define=my_value
INCLUDES=-I/usr/include/apache
LIBS=-L/usr/lib/apache/

all: local-shared-build

install: install-modules-yes

clean:
        -rm -f *.o *.lo *.slo *.la

You must now patch fcgi.h to fix the new API rename problem :

$ patch -Np0 -i fcgi.patch

fcgi.patch :

--- fcgi.h.orig    2003-02-04 00:07:37.000000000 +0100
+++ fcgi.h       2005-12-07 21:05:55.000000000 +0100
@@ -73,6 +73,36 @@
 #define ap_reset_timeout(a)
 #define ap_unblock_alarms()

+/* starting with apache 2.2 the backward-compatibility defines for
+ * 1.3 APIs are not available anymore. Define them ourselves here.
+ */
+#ifndef ap_copy_table
+
+#define ap_copy_table apr_table_copy
+#define ap_cpystrn apr_cpystrn
+#define ap_destroy_pool apr_pool_destroy
+#define ap_isspace apr_isspace
+#define ap_make_array apr_array_make
+#define ap_make_table apr_table_make
+#define ap_null_cleanup apr_pool_cleanup_null
+#define ap_palloc apr_palloc
+#define ap_pcalloc apr_pcalloc
+#define ap_psprintf apr_psprintf
+#define ap_pstrcat apr_pstrcat
+#define ap_pstrdup apr_pstrdup
+#define ap_pstrndup apr_pstrndup
+#define ap_push_array apr_array_push
+#define ap_register_cleanup apr_pool_cleanup_register
+#define ap_snprintf apr_snprintf
+#define ap_table_add apr_table_add
+#define ap_table_do apr_table_do
+#define ap_table_get apr_table_get
+#define ap_table_set apr_table_set
+#define ap_table_setn apr_table_setn
+#define ap_table_unset apr_table_unset
+
+#endif /* defined(ap_copy_table) */
+
 #if (defined(HAVE_WRITEV) && !HAVE_WRITEV && !defined(NO_WRITEV)) || defined WIN32
 #define NO_WRITEV
 #endif

[edit] Build mod_fastcgi

$ make
< become root >
$ make install

[edit] Configuration

You need to load the fastcgi module now.

Edit your apache httpd.conf file. To get it up and running add the following:

LoadModule fastcgi_module lib/apache/mod_fastcgi.so
<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
</IfModule>

This will take care of any file ending with .fcgi; remember standard cgi restrictions apply, files must be in a ExecCGI enabled or Script directory to execute.

If you are using php fastcgi you can modify the httpd.conf file this way:

LoadModule fastcgi_module  lib/apache/mod_fastcgi.so
<IfModule mod_fastcgi.c>
 ## Example for php fastcgi ###
 <Location /php-fcgi/>
   Options ExecCGI
   SetHandler fastcgi-script
 </Location>
 FastCGIExternalServer /php-fcgi/phpfcgi -host 127.0.0.1:9000
 AddType application/x-httpd-fastphp .php .cphp .php4 .php5
 Action application/x-httpd-fastphp /php-fcgi/phpfcgi
</IfModule>

This way all files that end in .php, .cphp, .php5, or .php4, should be handled (forwarded) to the fcgi server handler.

[edit] More

This guide currently doesn't cover setting up the external prespawned processes. To see examples of this, check the following links:
Lighttpd_For_Both_SSL_And_Non-SSL
Fastcgi_and_lighttpd

In order to get mod_fastcgi to compile using Apache 2.2.2 your must apply the following patch detailed here: http://fastcgi.com/archives/fastcgi-developers/2005-December/004060.html

[edit] Translation/ Other Languages

Français

Personal tools