How To php5 as cgi

Sorantis

Verified User
Joined
Sep 29, 2005
Messages
11
Location
Georgia
This is php5 as cgi installation guide.

Tested on FreeBSD 6.0

1. Download php5 archive from www.php.net

2. Untar it into any directory .

3. cd php_dir

4. ./configure \
--enable-force-cgi-redirect \
--prefix=/usr/local/php5 \
--with-config-file-path=/usr/local/php5 \
...
(add here additional options like :
--with-zlib \
--with-iconv=/sw/ \
--without-bundle-libxml \
--with-dom=/sw/ \
--with-libxml-dir=/sw/ \
--with-xsl=/sw/ \
--disable-pear \
--with-gd \
--with-freetype-dir=/sw/lib/freetype2/ \
--with-jpeg-dir=/sw/ \
--with-png-dir=/sw/ \
--with-mysql=/usr/local/mysql/ \
--enable-debug \)

2. make install clean

Your php5 now is installed in /usr/local/php5 directory

3. Edit your domain httpd.conf (not /etc/httpd/conf/httpd.conf)

# ScriptAlias /cgi-bin/ /home/admin/domains/www.yourdomain.com/public_html/cgi-bin/

ScriptAlias /cgi-bin/ /usr/local/php5/bin/

Options +ExecCGI

AddType php5-script .php5
AddHandler php5-script .php5

Action php5-script /cgi-bin/php
RemoveType .php

Save and restart apache. Now all files with .php5 extension are associated with php5

If you get Internal Server Error try following

chown -R admin:admin /usr/local/php5

Thats it.

Make sure that some_file.php5 has exec rights and begins with #!/usr/local/php5/bin/php
 
Last edited:
Back
Top