我看过这些教程:
> http://dbforch.wordpress.com/2010/05/21/apache2-fastcgi-multiple-php-versions-ubuntulucid-10-04/
> http://www.metod.si/multiple-php-versions-with-apache-2-fastcgi-phpfarm-on-ubuntu/
据我所知,我已经完成了所需的一切.问题是PHP根本不运行.当我转到http://localhost/somePHPfile.PHP时,它只输出PHP文件的来源.对于http://547.localhost/somePHPfile.PHP也是如此.
我会分解我采取的步骤,希望有人能够发现我错过的东西.
>首先我使用sudo apt-get install lamp-server ^ PHPmyadmin安装了一个默认的灯堆.在此之后,我有一个运行PHP的存储库版本的工作开发服务器.
>然后我使用PHPfarm创建两个PHP安装,一个用于5.3.17,另一个用于5.4.7. PHPfarm的地方是/ etc / PHP / PHPfarm,所以可执行文件在/ etc / PHP / PHPfarm / inst / PHP- {version} / bin中
>然后我启用suaxec和fastcgi for apache并用sudo a2enmod fastcgi actions suexec&& disabe mod_PHP sudo a2dismod PHP5
>接下来,我编辑了/etc/apache2/mods-enabled/fastcgi.conf来阅读:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /var/lib/apache2/fastcgi
FastCgiWrapper /usr/lib/apache2/suexec FastCgiConfig -idle-timeout
110 -killInterval 120 -pass-header HTTP_AUTHORIZATION -autoUpdate
ScriptAlias /PHP-fcgi/ /var/www/cgi-bin/
</IfModule>
>然后在/ var / www /我创建了一个文件夹cgi-bin,在这个文件夹中有两个文件,对于两个PHP版本中的每一个,如下所示(我只显示5.3.17 /var/www/PHP5317.fcgi中的一个) :
#!/bin/sh
# you can change the PHP version here.
version="5.3.17"
# PHP.ini file location,*/PHP-5.2.13/lib equals */PHP-5.2.13/lib/PHP.ini.
PHPRC=/etc/PHP/PHPfarm/inst/PHP-${version}/lib/PHP.ini
export PHPRC
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
# which php-cgi binary to execute
exec /etc/PHP/PHPfarm/inst/PHP-${version}/bin/php-cgi
>最后一步是创建虚拟主机.最后我在/ etc / apache2 / sites-enabled中有三个文件:000-default,PHP5.3.17和PHP5.4.7具有以下内容:
默认:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AddHandler php-cgi .PHP
Action php-cgi /PHP-fcgi/PHP5317.fcgi
</Directory>
</VirtualHost>
PHP5.3.17:
<VirtualHost *:80>
ServerName 5317.localhost
DocumentRoot /var/www
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AddHandler php-cgi .PHP
Action php-cgi /PHP-fcgi/PHP5317.fcgi
</Directory>
</VirtualHost>
PHP5.4.7:
<VirtualHost *:80>
ServerName 547.localhost
DocumentRoot /var/www
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AddHandler php-cgi .PHP
Action php-cgi /PHP-fcgi/PHP547.fcgi
</Directory>
</VirtualHost>
>最后我改变了/ etc / hosts来阅读
127.0.0.1 localhost 127.0.0.1 547.localhost 127.0.0.1 5317.localhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
现在我希望事情能够奏效,但遗憾的是他们没有.相反,PHP文件通过PHP运行,它只输出原始文件.
我必须在这里错过一些东西,但我已经多次完成这个过程,我无法弄清楚它出错的地方.
<FilesMatch "\.PHP$">
SetHandler php-cgi
</FilesMatch>
之前< /目录>在每个虚拟主机文件中.