我们目前的设置有使用mod_php由Apache服务的PHP脚本。 我们刚刚开发了一个需要通过CGI(它使用pcntl来分离一些进程)而不是mod_php的新脚本。 有人可以给我一个这样的例子configuration? 理想情况下,除了这个之外,我们可以通过mod_php运行所有的脚本,但是如果我们必须全部运行它们,那么我可以忍受这一点。
服务器的详细信息: Apache / 2.2.11(Ubuntu)PHP / 5.2.6-3ubuntu4与Suhosin-Patch
当前的configuration与它们来的一样简单( / etc / apache2 / sites-available / default ):
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks </Directory> <Directory /var/www/> Options FollowSymLinks MultiViews Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>
先谢谢您的帮助。
不要使用CGI:它比mod_php更慢。 需要fork的脚本可以使用shell命令启动( system()函数),并分发给它的心脏的内容:)
如果你仍然想要CGI,下面提示如何用.htaccess文件执行CGI处理程序的一些脚本: 运行php4和php5。
CGI是一个通用的网关界面,即你不需要为特定的语言进行设置。 但是,Apache通常会根据文件扩展名(如file.cgi与file.php)确定如何处理文件
您的Apache configuratin很可能已经设置为处理CGI程序,您可能只需要做两件事情
允许CGI从你所在的任何目录运行
<Directory /path/to/dir> Options +ExecCGI </Directory>
设置你想要的文件扩展名CGI(例如blah.phpcgi)
AddHandler cgi-script .phpcgi