Showing posts with label php apache cgi. Show all posts
Showing posts with label php apache cgi. Show all posts

Thursday, November 6, 2008

Run php as cgi in Apache

Download and intstall apache and php, I recommend using the tarball.
I installed apache in /usr/local/apache
./configure --prefix=/usr/local/apache;make;make install
and php reside in /usr/local/php
./configure --prefix=/usr/local/php/

Now you may edit the config file for apache
vim /usr/local/apache/conf/httpd.conf

you may place your .php file inside the document root directory
for me it is index.php
DocumentRoot "/usr/local/apache/htdocs/"
Inside the Directory section of "/usr/local/apache/htdocs/"
Options ExecCGI
AddType php-script .php #make sure there's no other type defined for .php
#Instead of AddType you may use AddHandler or SetHandler whichever is appropriate. See what is the differece, here.
Action php-script "/myphp-cgi/php-cgi"
Order allow,deny
Allow from all

ScriptAlias /myphp-cgi/ "/usr/local/php/bin/" #Map your php-binary location using ScriptAlias

You have to access the file appending /index.php unless you specify it with DirectoryIndex