====== PHP CGI ====== * [[Apache]] * [[Apache fcgid]] * [[Apache suExec]] * [[Apache Worker MPM PHP CGI Suexec Setup]] * [[PHP]] * [[http://www.php.net/manual/en/install.unix.commandline.php|CGI and command line setups]] * [[http://www.php.net/manual/en/security.cgi-bin.php|PHP CGI Security Considerations]] * [[http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html|Apache mod_fcgid]] * [[http://httpd.apache.org/docs/trunk/howto/cgi.html|Apache Tutorial: Dynamic Content with CGI]] * [[http://www.cyberciti.biz/tips/rhel-centos-fedora-apache2-fastcgi-php-configuration.html|Red Hat / CentOS Apache 2 FastCGI PHP Configuration]] === Gentoo === Install apache with threads, mpm worker, plus mod_fcgid package and add -D FCGID to apache2 conf. In the Directory configuration of every site, add this: Options -Indexes FollowSymLinks +ExecCGI AddType text/html .php .phps AddHandler php-fastcgi .php .html .htm .js Action php-fastcgi /cgi-bin/php.fcgi DirectoryIndex index.php index.html Add this so it is global: ScriptAlias /cgi-bin/ /var/www/localhost/cgi-bin/ Options +ExecCGI Order allow,deny Allow from all The ''php.fcgi'' file is created in ''/var/www/localhost/cgi-bin/''. It should be executable, and it holds the configuration settings for that CGI installation. #!/bin/bash PHP_CGI=/usr/lib/php5.3/bin/php-cgi PHP_FCGI_CHILDREN=4 PHP_FCGI_MAX_REQUESTS=1000 export PHP_FCGI_CHILDREN export PHP_FCGI_MAX_REQUESTS exec $PHP_CGI == Parsing .phps == If you want to use .phps to parse the source file and display it in colored format, you need to update the Apache config file and create a new CGI shell script with slight differences. AddHandler phps-fastcgi .phps Action phps-fastcgi /cgi-bin/phps.fcgi #!/bin/bash PHP_CGI="/usr/lib/php5.3/bin/php-cgi -s" ... === Migration to PHP CGI === There will be some things that need to change when migrating from a module to CGI. == .htaccess PHP changes == Things like php_value and php_flag must be put somewhere else. If you are running a custom php.ini for the site, you can make them directly there. Otherwise, you can use .user.ini and override php.ini changes. ==== Debugging ==== == No input file == If you run into an issue where it says "No input file specified", then the PHP binary is not executing the code for some reason, and will send a 404 HTTP header. Check the configuration file for errors, turn on error reporting, or watch the error log to flush out the issue. The most likely culprit is ''open_basedir''.