I have a site (based on ZEND framework) and hosted on 1and1 server.
1and1 server uses PHP version 5.2.17 and 5.4.5. I need to use PHP version 5.4.5 for a few files only. This is because some of my other files show a errors if I use PHP 5.4.5 but they execute fine using PHP 5.2.17.
On my .htaccess file the line below was written earlier to use PHP 5.2.17
AddType x-mapp-php5 .php
To use PHP 5.4.5 I have to use the the line below (instructions to use this code will be found on the 1and1 faq page)
AddHandler x-mapp-php6 .php
FAQ url(s):
Is there any way to use PHP 5.4.5 for those specific files only?
I tried to use the line below in .htaccess, but it's not working:
AddType x-mapp-php5 .php
AddHandler x-mapp-php6 FilenameController.php
EDIT
I tried to edit the 5.2 code. I am using PEAR packages to create Excel sheet which is working fine with PHP 5.2.17 but displaying the error below on PHP 5.4.5
Fatal error: Cannot redeclare _PEAR_call_destructors()
This change to the .htaccess
file
AddType x-mapp-php5 .php
AddHandler x-mapp-php6 .php6
SetEnv APPLICATION_ENV development
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^FilenameController\.php$ FilenameController.php6 [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
generates 404 "Page not found" error if I change the filename of FilenameController.php to FilenameController.php6 and when I am trying to visit the page its generating.
Why not just
AddHandler x-mapp-php6 .php6
And rename your 5.4 scripts to php6? You can even hide this from the user by doing the following in your .htaccess
file:
RewriteEngine On
RewriteBase /
RewriteRule ^FilenameController\.php$ FilenameController.php6 [L]
This does an internal direction to a .php6 extension for that one script file. :-)
However, let me emphasise: you can only choose which scripting engine to use on a per request basis not on a per file basis. For example: http:/yourdomain.com/FilenameController.php
will be handled by the PHP 5.4 RTS and all included files will be compiled and executed using PHP 5.4; http:/yourdomain.com/index.php
will be handled by the PHP 5.2 RTS and all included files will be compiled and executed using PHP 5.2.
You can't use 5.4 to compile on file within an application and 5.2 to compile the rest.
1and1 server uses PHP version 5.2.17 and PHP version 5.4.5.
I'd be curious as to the details of this.
Assuming you run php as an Apache module (mod_php), you can only have one version running on the same installation of Apache at a time. Are you sure that your server even allows to use both at the same time? More likely, you can restart Apache and have it run with a different version. If that is the case, you can't really configure your way out of this, lest you want to set up php over cgi.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With