I'm trying to execute different versions of PHP for different VirtualHosts
The default version of PHP is 5.3.3
I have installed a php v5.4.18 at /var/www/vhosts/
example.com/php-5.4.18 for the
example.com project
I have installed mod_fcgid to use it for new virtual hosts.
I'm testing with a phpinfo() file to get the php version used and see if php is executed via FastCGI in the new virtual host.
There is a problem to execute the file in the browser correctly.
The phpinfo.php file is not being executed the response is 500 status code (Internal Server Error)
The error_log:
[Tue Sep 10 18:48:29 2013] [warn] [client 192.168.1.12] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Tue Sep 10 18:48:29 2013] [error] [client 192.168.1.12] Premature end of script headers: phpinfo.php
I can execute the phpinfo.php file via CLI with
/var/www/vhosts/
example.com/php-5.4.18/bin/php-cgi /var/www/vhosts/
example.com/httpdocs/Symfony/web/phpinfo.php > /var/www/vhosts/
example.com/httpdocs/Symfony/web/phpinfo2.txt
At the txt file
X-Powered-By: PHP/5.4.18
<tr><td class="e">Server API </td><td class="v">CGI/FastCGI </td></tr>
Then is correct, when is executed via CLI.
This /var/www/vhosts/
example.com/php-5.4.18/bin/ directory is not in the PATH but if I add to the $PATH.
Which will be executed?
If there is another script with the same name php-cgi at /usr/bin which is already in the $PATH
The configuration:
-----------
<VirtualHost
192.168.1.12:80>
ServerName "example.com.localhost"
ServerAlias "www.example.com.localhost"
ServerAdmin "admin@xxxxxxxxxxx.localhost"
DocumentRoot /var/www/vhosts/
example.com/httpdocs/Symfony/web ErrorLog "/var/www/vhosts/
example.com/statistics/logs/error_log"
<Directory /var/www/vhosts/
example.com/httpdocs/Symfony/web>
AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /var/www/vhosts/
example.com/cgi-bin/php-fcgi .php
Order allow,deny
Allow from all
php_admin_value open_basedir ".:/var/www/vhosts/example.com:/usr/share/pear:/tmp"
php_admin_value include_path ".:/usr/share/pear"
</Directory>
<Directory "/var/www/vhosts/
example.com/cgi-bin">
SetHandler fcgid-script
Options +ExecCGI
# Customize the next two directives for your requirements.
Order allow,deny
Allow from all
</Directory>
# apache settings for virtual host
php_value memory_limit 256M
</VirtualHost>
------
The FCGIWrapper at /var/www/vhosts/
example.com/cgi-bin/php-fcgi:
------
#!/bin/sh
PHPRC=/var/www/vhosts/
example.com/php-5.4.18/etc/export PHPRC
PHP_CGI=/var/www/vhosts/
example.com/php-5.4.18/bin/php-cgi
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec $PHP_CGI
------
I have used this commands for the file
chmod +x php-fcgi, anyway has got 755
Why is working via CLi but is not working with the browser?